#9554: select related - maximum depth
-----------------------------------+----------------------------------------
          Reporter:  gert          |         Owner:  nobody        
            Status:  reopened      |     Milestone:                
         Component:  Contrib apps  |       Version:  1.0           
        Resolution:                |      Keywords:  select related
             Stage:  Unreviewed    |     Has_patch:  0             
        Needs_docs:  0             |   Needs_tests:  0             
Needs_better_patch:  0             |  
-----------------------------------+----------------------------------------
Changes (by gert):

  * status:  closed => reopened
  * resolution:  invalid =>
  * component:  Database layer (models, ORM) => Contrib apps

Comment:

 I think maybe a better place to address this issue is in the admin
 application by just adding a depth=3 parameter to the two select_related
 instructions in admin/views/main.py


 {{{
 def get_query_set(self):
     ...

         # Use select_related() if one of the list_display options is a
 field
         # with a relationship.
         if self.list_select_related:
             qs = qs.select_related(depth=3)
         else:
             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):
                         qs = qs.select_related(depth=3)
                         break


 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9554#comment:2>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to