Code

Opened 2 years ago

Closed 20 months ago

Last modified 20 months ago

#17646 closed New feature (fixed)

Create a get_list_filter hook in ModelAdmin

Reported by: rasca Owned by: mateusgondim
Component: contrib.admin Version: master
Severity: Normal Keywords:
Cc: rasca7@…, mmitar@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

This would be useful when for example the queryset is filtered based on a user type and the superuser can see all types. For a superuser one could add a the type field to list_display and list_filter.

Attachments (1)

ticket17646.diff (6.1 KB) - added by mateusgondim 2 years ago.
I created the hook there in options.py and replaced it in another method that was using the property directly.i also added a doc about the new method in the index.txt of admin, and in the section of minor features in release notes.Finally, i added a test in regression tests about that.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 2 years ago by rasca

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Maybe also creating hooks for all the remaining ModelAdmin properties.

comment:2 Changed 2 years ago by julien

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 2 years ago by rasca

See also #17006 and #16841

comment:4 Changed 2 years ago by mateusgondim

  • Owner changed from nobody to mateusgondim

Changed 2 years ago by mateusgondim

I created the hook there in options.py and replaced it in another method that was using the property directly.i also added a doc about the new method in the index.txt of admin, and in the section of minor features in release notes.Finally, i added a test in regression tests about that.

comment:5 Changed 2 years ago by mateusgondim

  • Has patch set

comment:6 Changed 2 years ago by mitar

  • Cc mmitar@… added

comment:7 Changed 20 months ago by frecon

  • Needs tests set

comment:8 Changed 20 months ago by frecon

  • Needs tests unset

comment:9 Changed 20 months ago by Julien Phalip <jphalip@…>

  • Resolution set to fixed
  • Status changed from new to closed

In ae206d78f6d991e1d7ea1c1bb8bd85f4658c0877:

Fixed #17646 -- Added a get_list_filter() method to ModelAdmin. Thanks to rasca for the suggestion and to mateusgondim for the patch.

comment:10 Changed 20 months ago by Julien Phalip <jphalip@…>

In 22ca5bab95d65d0fdec0b6914f9ab96795cfe138:

[1.5.x] Fixed #17646 -- Added a get_list_filter() method to ModelAdmin. Thanks to rasca for the suggestion and to mateusgondim for the patch.
Backport of ae206d78f6d991e

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.