Re: Using {% include %} and getting context with me

2019-02-13 Thread Mikkel Kromann
bruar 2019 kl. 15.47.10 UTC+1 skrev Mikkel Kromann: > > Hi. > > I have a collection of apps where I find repeating myself when rendering > tables in the templates. > In the stylised example below I have three types of tables, foo, bar and > baz. > Each app is supposed to ren

Using {% include %} and getting context with me

2019-02-13 Thread Mikkel Kromann
Hi. I have a collection of apps where I find repeating myself when rendering tables in the templates. In the stylised example below I have three types of tables, foo, bar and baz. Each app is supposed to render various combinations of tables from its own models, but also from other models'

Re: How can I read child model class' DecimalField attribute 'decimal_places' from inside a parent Meta class

2018-12-27 Thread Mikkel Kromann
, but not from the parent class. Mikkel torsdag den 27. december 2018 kl. 20.59.43 UTC+1 skrev Mikkel Kromann: > > > Hello. > > I have a parent Meta class and some child classes. > I would like to read the decimal_places attribute from DecimalField of my > child instances using a

How can I read child model class' DecimalField attribute 'decimal_places' from inside a parent Meta class

2018-12-27 Thread Mikkel Kromann
Hello. I have a parent Meta class and some child classes. I would like to read the decimal_places attribute from DecimalField of my child instances using a function in my parent class. I am able to read the attribute from inside my child classes, but I cant crack how to read from a function in

Point-in-Time version history with Django with propose and commit or reject

2018-10-01 Thread Mikkel Kromann
Dear Django users. I am looking into the so-called Point-In-Time architecture for databases with version history. See e.g. https://www.red-gate.com/simple-talk/sql/database-administration/database-design-a-point-in-time-architecture/ One reason I like PTA is that a version history for my

Re: GROUP BY

2018-08-14 Thread Mikkel Kromann
the columns you specify. > > > > I suggest reviewing the annotation and values docs here: > > > https://docs.djangoproject.com/en/2.1/topics/db/aggregation/#order-of-annotate-and-values-clauses > > > > > > *From:* django...@googlegroups.com [mailto: &g

Re: GROUP BY

2018-08-14 Thread Mikkel Kromann
_row is a dictionary, so you need > to access it as if it were a dictionary. > > contract_sum = contract_row['contracted'] > > > > *From:* django...@googlegroups.com [mailto: > django...@googlegroups.com ] *On Behalf Of *Mikkel Kromann > *Sent:* Monday, August 13, 2018 11:51 PM

Re: GROUP BY

2018-08-14 Thread Mikkel Kromann
t; *From:* django...@googlegroups.com [mailto: > django...@googlegroups.com ] *On Behalf Of *Mikkel Kromann > *Sent:* Monday, August 13, 2018 11:51 PM > *To:* Django users > *Subject:* Re: GROUP BY > > > > > > Thanks. But strange - exactly same error: > >

Re: GROUP BY

2018-08-13 Thread Mikkel Kromann
t; > > > > > *From:* django...@googlegroups.com [mailto: > django...@googlegroups.com ] *On Behalf Of *Mikkel Kromann > *Sent:* Monday, August 13, 2018 3:22 PM > *To:* Django users > *Subject:* GROUP BY > > > > I'm trying to sum the field "

GROUP BY

2018-08-13 Thread Mikkel Kromann
I'm trying to sum the field "ownProduction", grouping it by the foreign key "market" (using the market's human readable name, __name from the Market table) and the week number (which is built-in function __year of the date field "dateContract"). However, when I try to read the results of the

Re: A query with "GROUP BY" and summation of products of two columns

2018-08-04 Thread Mikkel Kromann
') .annotate(contract_sum=Sum('contractSum')) .annotate(expected_own_production_sum=Sum( 'id', field='contractSum * probability')) ) cheers, Mikkel lørdag den 4. august 2018 kl. 14.11.27 UTC+2 skrev Mikkel Kromann: > > Dear

A query with "GROUP BY" and summation of products of two columns

2018-08-04 Thread Mikkel Kromann
Dear Django users. I'm trying to do the sums of the product of two columns ('contract_sum' and 'probability', decimal fields), grouping by a third column, 'stage' (a choice variable). I'm also reporting the grouped sums of one of the single columns ('contract_sum') The single column works just

Re: Is it possible to construct reversible url names in urls.py using , regex etc

2018-06-25 Thread Mikkel Kromann
urn paths >From urls.py: from . models import GetItemPaths urlpatterns = GetItemPaths() + [ path('/to/some/other/views/'otherview.asView(), name='other_name'), ] lørdag den 23. juni 2018 kl. 15.08.04 UTC+2 skrev Melvyn Sopacua: > > On zaterdag 23 juni 2018 14:30:08 CEST Mikkel K

Re: Is it possible to construct reversible url names in urls.py using , regex etc

2018-06-23 Thread Mikkel Kromann
no attribute '_default_manager' So it certainly seems that using model=i will not pass the model name. Is this because the argument for model= expects not a string but an object? thanks, Mikkel torsdag den 21. juni 2018 kl. 10.19.08 UTC+2 skrev Mikkel Kromann: > > I have a lot of model

Is it possible to construct reversible url names in urls.py using , regex etc

2018-06-21 Thread Mikkel Kromann
I have a lot of models (say 30 or 40) which are so similar, that I have handled them using slightly modified class based views. In urls.py: urlpatterns = [ path('list//',ItemListView.as_view()), path('create//', ItemCreateView.as_view()), path('update//',

Re: Help with context_processor

2018-06-20 Thread Mikkel Kromann
me': >> 'region_list' }, >> >> {'name': 'location', 'readable': 'Location', 'urlname': >> 'location_list' } >> >> ] >> >> } >> >> >> >> Then in the template: >> >> {% for item in Items %} >> {{ite

Re: Help with context_processor

2018-06-19 Thread Mikkel Kromann
t > is the way you are creating the dictionary in your context processor. > > Best regards, > > Andréas > > 2018-06-18 21:16 GMT+02:00 Mikkel Kromann >: > >> Hi. >> >> Once again thanks for all your invaluable advice to me so far. Now, I'm >> battling

Help with context_processor

2018-06-18 Thread Mikkel Kromann
Hi. Once again thanks for all your invaluable advice to me so far. Now, I'm battling context_processors. I really struggle to find a good example that can help me understand how to use them. They seem quite helpful to a lot of stuff I plan to do. I think I got the configuration in settings.py

Re: Nested for loops in templates

2018-06-15 Thread Mikkel Kromann
ngo-template?utm_medium=organic_source=google_rich_qa_campaign=google_rich_qa > > > > > > *From:* django...@googlegroups.com [mailto: > django...@googlegroups.com ] *On Behalf Of *Mikkel Kromann > *Sent:* Wednesday, June 13, 2018 3:54 PM > *To:* Django users > *Subje

Re: Nested for loops in templates

2018-06-15 Thread Mikkel Kromann
a list of the > values in the order that they should appear > > On Wed, Jun 13, 2018 at 4:54 PM Mikkel Kromann > wrote: > >> Dear Django users. >> >> Thanks to the good advice of many people on this list, I've managed to >> create some nice generic class

Nested for loops in templates

2018-06-13 Thread Mikkel Kromann
Dear Django users. Thanks to the good advice of many people on this list, I've managed to create some nice generic class based views that work simultaneously with many models. The models may differ from each other with regards to the number of columns in their data tables as well as the naming

Re: Accessing the model attribute of UpdateView & friends

2018-06-07 Thread Mikkel Kromann
our code try to do something weird. > > Anyway, good luck on your project! > > On Wed, Jun 6, 2018, 14:51 Mikkel Kromann > wrote: > >> Thanks Daniel. >> >> Both your proposed solutions worked very well. >> For now, I don't have other information stuffed i

Re: Accessing the model attribute of UpdateView & friends

2018-06-06 Thread Mikkel Kromann
elds to display to the user based on which model the > user is updating, so you could just specify the form_class attribute on the > path (just as you did with the model). > > Hope it helps! > > > On Wed, Jun 6, 2018, 10:36 Mikkel Kromann > wrote: > >> Hello Daniel. >&

Re: Accessing the model attribute of UpdateView & friends

2018-06-06 Thread Mikkel Kromann
es of the Model, you used to be able to call a > .get_field_names() or something like that but that is depreciated since > 1.10. Now to do that you should use the Model._meta to get_fields(). Check > the documentation for the Model._meta to check its full potential. > > Hope it helps! > > O

Re: Accessing the model attribute of UpdateView & friends

2018-06-06 Thread Mikkel Kromann
> > Regards, > > Andréas > > 2018-06-05 21:56 GMT+02:00 Mikkel Kromann >: > >> Dear Django-users. >> >> I'm slowly working towards a Django "data-warehouse" framework, where I >> can easily add a lot of models (each containing a t

Accessing the model attribute of UpdateView & friends

2018-06-05 Thread Mikkel Kromann
Dear Django-users. I'm slowly working towards a Django "data-warehouse" framework, where I can easily add a lot of models (each containing a table with data), while sticking to only few reusable views. I've realised that in urls.py, it is possible to specify the model on which the UpdateView

Re: Re-using CreateView, UpdateView & friendship

2018-04-29 Thread Mikkel Kromann
skrev Mikkel Kromann: > > Dear Django users. > > I'm testing whether Django is a good choice for a web based application > that I need to handle (create, read, update, delete) a lot of data tables. > I've discovered the built-in Class Based View, which are going to save me > fro

Re-using CreateView, UpdateView & friendship

2018-04-29 Thread Mikkel Kromann
Dear Django users. I'm testing whether Django is a good choice for a web based application that I need to handle (create, read, update, delete) a lot of data tables. I've discovered the built-in Class Based View, which are going to save me from a lot of repetitive code lines - yay! Now, I've

Re: Advice needed: One big model or many apps with highly interlinked data tables?

2018-04-23 Thread Mikkel Kromann
. cheers, Mikkel lørdag den 14. april 2018 kl. 16.10.27 UTC+2 skrev Mikkel Kromann: > > Hi. > > I'm new to Django, and I'm working my way into Django by going through the > nice Djangoproject.com turorial. > I'm trying to find out whether Django is the right tool for my task,

Advice needed: One big model or many apps with highly interlinked data tables?

2018-04-14 Thread Mikkel Kromann
Hi. I'm new to Django, and I'm working my way into Django by going through the nice Djangoproject.com turorial. I'm trying to find out whether Django is the right tool for my task, which is maybe a bit unusual for Django. My task is to build a web interface to a database for an calculation