Optimizing admin change view with inlines

2014-12-23 Thread 'Petros Moisiadis' via Django users
Hello people :) I am struggling with optimizing an admin with inlines which causes too many database requests. My model structure is like this: class ExampleA(models.Model): ... class ExampleB(models.Model): aexample = models.ForeignKey('ExampleA', related_name='bexam

Re: Optimizing admin change view with inlines

2014-12-24 Thread 'Petros Moisiadis' via Django users
On 12/23/14 19:13, 'Petros Moisiadis' via Django users wrote: > Hello people :) > > I am struggling with optimizing an admin with inlines which causes too > many database requests. > > My model structure is like this: > > class ExampleA(models.Model): > ... > > class ExampleB(mo

Re: Optimizing admin change view with inlines

2014-12-24 Thread 'Petros Moisiadis' via Django users
On 12/24/14 13:30, 'Petros Moisiadis' via Django users wrote: > On 12/23/14 19:13, 'Petros Moisiadis' via Django users wrote: >> Hello people :) >> >> I am struggling with optimizing an admin with inlines which causes too >> many database requests. >> >> My model structure is like this: >> >> c

Re: Optimizing admin change view with inlines

2014-12-28 Thread Collin Anderson
Hi Petros, I think the raw_id_fields still display the __str__/__unicode__ of the selected object so therefore need to get queried. I wonder if select_related would possibly help? Collin On Wednesday, December 24, 2014 5:53:02 AM UTC-6, Ernest0x wrote: > > On 12/24/14 13:30, 'Petros Moisiadis'

Re: Optimizing admin change view with inlines

2014-12-29 Thread 'Petros Moisiadis' via Django users
Hello Collin, On 12/29/14 07:25, Collin Anderson wrote: > Hi Petros, > > I think the raw_id_fields still display the __str__/__unicode__ of the > selected object so therefore need to get queried. I wonder if > select_related would possibly help? > I do have select_related in the queryset (look at

Re: Optimizing admin change view with inlines

2015-01-01 Thread Collin Anderson
Hi Petros, I think it's because "value_from_object" only passes the primary key of the object and then raw_id_field re-queries it. https://github.com/django/django/blob/40ccef16/django/contrib/admin/widgets.py#L195 https://github.com/django/django/blob/40ccef16/django/forms/models.py#L151 https: