Code

Opened 6 years ago

Closed 6 years ago

#8213 closed (wontfix)

Make use of "select_related(tables)" in admin

Reported by: Reflejo Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

There is an easy way to make use of select_realated(tables) features in ModelAdmin. By now list_select_related is expecting boolean type but i made a minor change to expect list or tuple. In this way we can specify join tables instead of join all of them.

The change is backward compatible.

Attachments (1)

select_related_list.patch (1.4 KB) - added by Reflejo 6 years ago.
patch against #8290

Download all attachments as: .zip

Change History (2)

Changed 6 years ago by Reflejo

patch against #8290

comment:1 Changed 6 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

Actually, you don't need this patch at all; you can just override ModelAdmin.queryset() to do whatever you need there. e.g.:

class MyModelAdmin(ModelAdmin):
    def queryset(self):
        return super(MyModelAdmin, self).queryset().select_related('foo__bar__baz', depth=2)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.