Though it's a little hard to tell from your post, this sounds more like it's definitely a case where your code needs improvement. From what I understand, the database hits are coming from your custom AJAX, not from the admin's default behavior. Also, you already know the solution: use select_related. If you are saying that django ORM should make select_related=True the default - no. That would be bad. Every query for a model with a foreign key would be bloated by the additional joins and selects, whether or not any of the data on the fk was being used. Overall efficiency might actually decrease. To put it another way, "Premature optimization is the root of all evil." Best, Stephen
On Feb 13, 10:35 pm, Matteius <matte...@gmail.com> wrote: > I have a very small test database on my test development virtualbox > environment and so while I've been adding in custom AJAX for dynamic > ForeignKey filters (in the case of Enrollment's Assignment list) I > noticed that because I'm using the Django Debug Toolbar. Well on > these pages with only ~28 Enrollments I get hit up with 72 queries and > the page takes 780 ms to load. Well this could probably be solved by > adding select_related() to the lookups on foreign key fields or at > least something. This is terrible default behavior, but I can't > really ship an admin interface to the client without showing the > relationship in the system. This is definitely a case where the admin > needs improvement. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.