Code

Opened 6 years ago

Closed 5 years ago

Last modified 3 years ago

#9969 closed (fixed)

Admin changelist table field and list_filter section broken when field value has been chosen from a choices named group

Reported by: ramiro Owned by: ramiro
Component: contrib.admin Version: master
Severity: Keywords: change list choices columns (None) named groups select dropdown
Cc: sixthgear Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

After [7977], with this setup:

#models.py
from django.db import models

CAT_CHOICES = (
   ('Outer 1', (
           ('option1', 'Inner 1'),
           ('option2', 'Inner 2'),
       )
   ),
  ('normal', 'Normal no nested value'),
)

class Item(models.Model):
    name = models.CharField(max_length=60)
    category = models.CharField("Item Category", max_length=30, choices=CAT_CHOICES)
# admin.py

from t9969.models import Item
from django.contrib import admin

class ItemAdmin(admin.ModelAdmin):
    list_display = ('name', 'category',)

admin.site.register(Item, ItemAdmin)

After adding some Items choosing each of the three available Category field values offered by the select widget, the change list shows None() for the instances with the values 'option1' and 'option2' (should be 'Inner 1' and 'Inner 2' respectively), 'Normal no nested value' shows correctly.

Attachments (8)

t9969-r9701.diff (1.3 KB) - added by ramiro 6 years ago.
Patch thta fixes the issue, no tests yet
t9969-r9708.diff (3.5 KB) - added by ramiro 6 years ago.
New patch, includes tests
9969-r9891.diff (16.7 KB) - added by ramiro 5 years ago.
Updated and correct patch
no-hierarchy-no-category-names.png (18.4 KB) - added by ramiro 5 years ago.
screenshot showing problem with changelist field
list_filter_bug.png (6.8 KB) - added by ramiro 5 years ago.
screenshot showing problem with list_filter section
9969-admin-bugs-with-nested-choices-r9905.diff (6.4 KB) - added by ramiro 5 years ago.
Updated patch includes fixes for poblems in changelist tabel and in filter section, includes tests
9969-admin-bugs-with-nested-choices-r10283.diff (6.2 KB) - added by ramiro 5 years ago.
Patch updated to apply cleanly to trunk as of r10283
9969-backport-to-1.0.x.diff (5.6 KB) - added by ramiro 5 years ago.
Patch backported to 1.0.X branch

Download all attachments as: .zip

Change History (20)

Changed 6 years ago by ramiro

Patch thta fixes the issue, no tests yet

comment:1 Changed 6 years ago by ramiro

  • Has patch set
  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset

comment:2 Changed 6 years ago by SantiagoZarate

I've just patched my sistem... works perfectly!

Thanks ramiro!

comment:3 Changed 6 years ago by anonymous

  • Needs tests unset
  • Owner changed from nobody to ramiro

Changed 6 years ago by ramiro

New patch, includes tests

Changed 5 years ago by ramiro

Updated and correct patch

comment:4 Changed 5 years ago by anonymous

I've updated/fixed the patch:

  • The previous patch contained only the regression tests, I've fixed that now by including the actual code fix too.
  • Updated to current trunk status, more specifically the mods to the admin_views regression tests were adapted to post [9739]

comment:5 Changed 5 years ago by ramiro

(oops, last comment was mine)

comment:6 Changed 5 years ago by ramiro

  • Summary changed from Admin change list view shows (None) instead of the real field value when it has been chosen from a choices named group to Admin changelist table field and list_filter section broken when field value has been chosen from a choices named group

Changed 5 years ago by ramiro

screenshot showing problem with changelist field

Changed 5 years ago by ramiro

screenshot showing problem with list_filter section

Changed 5 years ago by ramiro

Updated patch includes fixes for poblems in changelist tabel and in filter section, includes tests

comment:7 Changed 5 years ago by sixthgear

  • Cc sixthgear added

comment:8 Changed 5 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Unreviewed to Accepted

Changed 5 years ago by ramiro

Patch updated to apply cleanly to trunk as of r10283

comment:9 Changed 5 years ago by Alex

  • Triage Stage changed from Accepted to Ready for checkin

comment:10 Changed 5 years ago by Alex

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

Fixed in r10318.

Changed 5 years ago by ramiro

Patch backported to 1.0.X branch

comment:11 Changed 5 years ago by jacob

(In [10340]) [1.0.X] Fixed #9969: choices with options groups (added in [7977]) now work correctly in the admin with list_display and list_filter. Thanks, ramiro. Backport of r10318 from trunk; thanks, cramm.

comment:12 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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.