Hello Javier,

I did the verification to see what is taking so much time to  fetch and I
realise it is because my model "TmyObject" is related to another class
model driving his caracteristics. For example, it's like

                   TmyObject can be any car

                  I have another model called "TobjectType" who is a list
of car type (SUV, trucks,  etc.)
                  I have a model called "TObjectAttribute" who is the
generic list of car caracteristics (how many doors, horse power, 4 weels
drive,  etc)
                 I have a model called TrTypeAttributeList to generate a
list of attribute for a type (ex.: SUV has doors, horse power,  weel drive,
etc.)
                 Finally, I have a model called TrObjectCaracteristic who
has 2 FK, one from TmyObject and one from TrTypeAttributeList and a value
field. I did not define a __unicode__ method for TrObjectCaracteristic.

This is what is taking the most of the time. the gattering of the list of
TObjectAttribute, 3 or 4  times each at a time because TmyObject has 3-4
attributes value. Because I called it as an admin.StackedInline object in
the admin page.

I don't know how to resolve this issue.

Regards,

VB

2012/3/13 Javier Guerra Giraldez <jav...@guerrag.com>

> On Tue, Mar 13, 2012 at 2:14 PM, Phanounou <virginia.bel...@gmail.com>
> wrote:
> > Hello,
> >
> >  have tryed to use the  formfield_for_foreignkey() and
> > formfield_for_manytomany() in the admin.py file. In fact, I have reduced
> > the reponse time (around 10 sec. less then before) by replacing extra =
> 2 by
> > extra=0 in my admin.StackedInline objects. It still taking 20-24 seconds
> to
> > edit an object in the admin interface. The 2 methods mention on top did
> not
> > help to reduce the time. I don't know what else to try now I'm stuck. Any
> > one has a subjection?
>
>
> this is what did the trick for me:
>
>        def formfield_for_foreignkey(self, db_field, request, **kwargs):
>                if db_field.name == 'pagina':
>                        kwargs['queryset'] = Pagina.objects.select_related()
>                return super(EventAdmin,
> self).formfield_for_foreignkey(db_field,
> request, **kwargs)
>
>
> in short, it adds the select_related() to the queryset used for the
> 'pagina' foreign key.  that was needed because the __unicode__()
> method of the Pagina model uses some related fields.
>
> but you still haven't verified what generates the thousands of
> queries.  take the tieme to read the SQL generated to see what is it
> fetching and why.
>
>
> --
> Javier
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to