While I've been working on composite primary keys, I also made a few
tweaks to the admin app. Most of these are related to the primary key
support, but one is an optimization.

I would post this as a patch, or a ticket, but I want to open this up
for discussion, and my django repo is so far from trunk it's a PITA at
the moment to create the patch.

Anyways, what it does:

* list_select_related can be a boolean, or a list. If it's a list it
says "select_related on these fields"
* select_related is smart by default, no more implicit select all

If someone wants to create a patch, you'll be able to get to it a lot
faster than I will. Otherwise I'll eventually throw one up on trac for
each change.

line 198ish of django.contrib.admin.views.main

        if isinstance(self.list_select_related, (tuple, list)):
            qs = qs.select_related(*self.list_select_related)
        elif self.list_select_related:
            qs = qs.select_related()
        else:
            fields = []
            for field_name in self.list_display:
                try:
                    f = self.lookup_opts.get_field(field_name)
                except models.FieldDoesNotExist:
                    pass
                else:
                    if isinstance(f.rel, models.ManyToOneRel):
                        fields.append(name)
            if fields:
                qs = qs.select_related(*fields)
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to