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' tabl

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

2018-12-27 Thread Mikkel Kromann
class, 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 ins

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 projec

Re: GROUP BY

2018-08-14 Thread Mikkel Kromann
values function. Values limits the result set > to 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 > > > > &g

Re: GROUP BY

2018-08-14 Thread Mikkel Kromann
irsdag den 14. august 2018 kl. 15.28.01 UTC+2 skrev Matthew Pava: > > Ah, the error has the answer. contract_row is a dictionary, so you need > to access it as if it were a dictionary. > > contract_sum = contract_row['contracted'] > > > > *From:* django...@googlegroups

Re: GROUP BY

2018-08-14 Thread Mikkel Kromann
ct_row['contracted'] > > > > *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 > > > > > > Th

Re: GROUP BY

2018-08-13 Thread Mikkel Kromann
“ownProduction” in your values list prior to the > annotation. > > > > > > *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

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 que

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

2018-08-04 Thread Mikkel Kromann
stage') .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

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
=i+'_update' ) ) paths.append(path( 'delete/'+i+'//', ItemDeleteView.as_view( model=m),name=i+'_delete' ) ) return paths >From urls.py: from . models import GetItemPaths urlpatterns = GetItemPaths() + [ path('/to/some/other/views

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

2018-06-23 Thread Mikkel Kromann
del1 I get the following error: 'str' object has 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

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//', Ite

Re: Help with context_processor

2018-06-20 Thread Mikkel Kromann
nt to loop over something use a >> list. Like this: >> >> >> >> return { >> >> 'items': [ >> >>{'name': 'year', 'readable': 'Year', 'urlname': 'year_list' }, >> &g

Re: Help with context_processor

2018-06-19 Thread Mikkel Kromann
> {% block sidebar %} > > {{year.readable}} > {{region.readable}} > {{location.readable}} > > {% endblock %} > > The reason for needing to add year, region and location, is because that > is the way you are creating the dictionary in your context processor. &g

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 a

Re: Nested for loops in templates

2018-06-15 Thread Mikkel Kromann
n-a-django-template?utm_medium=organic&utm_source=google_rich_qa&utm_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 u

Re: Nested for loops in templates

2018-06-15 Thread Mikkel Kromann
ple each row as 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

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
t is invalid, making your 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 ha

Re: Accessing the model attribute of UpdateView & friends

2018-06-06 Thread Mikkel Kromann
e which form fields 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: > >>

Re: Accessing the model attribute of UpdateView & friends

2018-06-06 Thread Mikkel Kromann
he 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! >

Re: Accessing the model attribute of UpdateView & friends

2018-06-06 Thread Mikkel Kromann
in the > class? > > 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 (ea

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 i

Re: Re-using CreateView, UpdateView & friendship

2018-04-29 Thread Mikkel Kromann
6.01 UTC+2 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

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 g

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

2018-04-23 Thread Mikkel Kromann
eeded. 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

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 too