Code

Opened 5 years ago

Closed 5 years ago

#11848 closed (duplicate)

Hook to be able to customize changelist_view

Reported by: igors 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: UI/UX:

Description

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 igors 5 years ago.
queryset_changelist.patch (1.6 KB) - added by igors 5 years ago.

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by igors

Changed 5 years ago by igors

comment:1 Changed 5 years ago by kmtracey

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

#10761 is already open requesting this.

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.