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.