Opened 11 years ago

Closed 11 years ago

#11848 closed (duplicate)

Hook to be able to customize changelist_view

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


Currently, the changelist_view uses self.queryset to display the list of objects instances. So, to customize what changelist will use, you need to customise self.queryset. The bad point is that change_view also uses self.queryset, and maybe you don't wan't do affect it.

For example: I have a list of Page objects, that could have subpages. The subpages are Pages too, but are not listed in changelist. But you should be able to edit subpages (since they are Page objects). I've attached an image of my admin with this use case.
If I customize self.queryset to hide subpages (in changelist view), I can't access subpages form (change view) anymore.

I've attached a patch fix this. Just creating a self.queryset_changelist hook. And changing ChangeList to use it. Now I can customize what changelist will show me, without affecting what I can edit.

Attachments (2)

Picture 2.png (44.0 KB) - added by Igor Sobreira 11 years ago.
queryset_changelist.patch (1.6 KB) - added by Igor Sobreira 11 years ago.

Download all attachments as: .zip

Change History (3)

Changed 11 years ago by Igor Sobreira

Attachment: Picture 2.png added

Changed 11 years ago by Igor Sobreira

Attachment: queryset_changelist.patch added

comment:1 Changed 11 years ago by Karen Tracey

Resolution: duplicate
Status: newclosed

#10761 is already open requesting this.

Note: See TracTickets for help on using tickets.
Back to Top