Dear all,

I am facing an important optimisation problem due to the Django's
admin interface.

Here is the structure of my models, which are not very complicated nor
exotic:
models.py
class A:
  [some fields]
class B:
  [some fields]
class C:
  [some fields]

class A_B:
  a = ForeignKey(A)
  b = ForeignKey(B)
  [some fields]

class A_C:
  a = ForeignKey(A)
  c = ForeignKey(C)
  [some fields]

class B_C:
  b = ForeignKey(B)
  c = ForeignKey(C)
  [some fields]

Here is my admin file:
admin.py
class A_B_line(admin.TabularInline):
  model = A_B
class A_C_line(admin.TabularInline):
  model = A_C
class B_C_line(admin.TabularInline):
  model = B_C
class A_admin(admin.modelAdmin):
  inlines = [ A_C_line, A_B_line ]
class B_admin(admin.modelAdmin):
  inlines = [ A_B_line, B_C_line ]
class C_admin(admin.modelAdmin):
  inlines = [ A_C_line, B_C_line ]

(In the real application, instead of three A, B, C basic classes, I
have around 40 such classes, and a lot of "A_B"-like classes.)

The problem is that I have several hundreds instances of each type A,
B, C, ..., and displaying one "A" object (using its __unicode__
method) requires several other database queries.

Due to all these connections, displaying a single admin page usually
takes 10 or 15 seconds when trying to modifying an object.
A profiler middleware says that I have 4381304 function calls (4148569
primitive calls) in 12.432 CPU seconds.

I know that if I remove the inline fields from the admin page, I
obtain reasonable generation times, but the admin site is (by far)
less friendly without them.
My idea is to customize the InlineAdmin, to cache data which are
displayed in select fields instead of recomputing them in each view.

Do you think that is a good idea, or have I missed something better?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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