Code

Opened 3 years ago

Closed 3 years ago

#16080 closed Bug (fixed)

list_filter broken for fields with lenght 2

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

Description

Commit 16144 broke list_filter refering to model fields, when its name is just 2 chars long.

Consider admin options class having

class VenueOptions(admin.ModelAdmin)
    list_filter = ('at', 'when',)

Then in django/contrib/admin/validation.py loops over items in list_filter this way:

                   # item = 'at'

                   #....

76                 try:
77                     # Check for option #2 (tuple)                                                                                                          
78                     field, list_filter_class = item
79                 except (TypeError, ValueError):
80                     # item is option #1
81                     field = item

The check for tuple will fail, since the result would be

field, list_filter_class = 'at'
# results in:
field = 'a'
list_filter_class = 't'

(Tested on svn rev: 16270)

Attachments (1)

16080.two-character-listfilter.diff (6.9 KB) - added by julien 3 years ago.
Fix + tests

Download all attachments as: .zip

Change History (4)

comment:1 Changed 3 years ago by anonymous

  • Easy pickings set
  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted

Changed 3 years ago by julien

Fix + tests

comment:2 Changed 3 years ago by julien

  • Easy pickings unset
  • Has patch set
  • Needs tests unset

comment:3 Changed 3 years ago by jezdez

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

In [16274]:

Fixed #16080 -- Handle admin list filter items with two characters better. Thanks, Ales Zoulek and Julien Phalip.

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.