Opened 8 years ago

Closed 8 years ago

#8213 closed (wontfix)

Make use of "select_related(tables)" in admin

Reported by: Martín Conte Mac Donell 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 Martín Conte Mac Donell 8 years ago.
patch against #8290

Download all attachments as: .zip

Change History (2)

Changed 8 years ago by Martín Conte Mac Donell

Attachment: select_related_list.patch added

patch against #8290

comment:1 Changed 8 years ago by Jacob

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: wontfix
Status: newclosed

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)
Note: See TracTickets for help on using tickets.
Back to Top