Opened 8 years ago

Closed 7 years ago

Last modified 5 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 Morales Owned by: Ramiro Morales
Component: contrib.admin Version: master
Severity: Keywords: change list choices columns (None) named groups select dropdown
Cc: Joshua Cender 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 Morales 8 years ago.
Patch thta fixes the issue, no tests yet
t9969-r9708.diff (3.5 KB) - added by Ramiro Morales 8 years ago.
New patch, includes tests
9969-r9891.diff (16.7 KB) - added by Ramiro Morales 8 years ago.
Updated and correct patch
no-hierarchy-no-category-names.png (18.4 KB) - added by Ramiro Morales 8 years ago.
screenshot showing problem with changelist field
list_filter_bug.png (6.8 KB) - added by Ramiro Morales 8 years ago.
screenshot showing problem with list_filter section
9969-admin-bugs-with-nested-choices-r9905.diff (6.4 KB) - added by Ramiro Morales 8 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 Morales 7 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 Morales 7 years ago.
Patch backported to 1.0.X branch

Download all attachments as: .zip

Change History (20)

Changed 8 years ago by Ramiro Morales

Attachment: t9969-r9701.diff added

Patch thta fixes the issue, no tests yet

comment:1 Changed 8 years ago by Ramiro Morales

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

comment:2 Changed 8 years ago by Santiago Zarate

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

Thanks ramiro!

comment:3 Changed 8 years ago by anonymous

Needs tests: unset
Owner: changed from nobody to Ramiro Morales

Changed 8 years ago by Ramiro Morales

Attachment: t9969-r9708.diff added

New patch, includes tests

Changed 8 years ago by Ramiro Morales

Attachment: 9969-r9891.diff added

Updated and correct patch

comment:4 Changed 8 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 8 years ago by Ramiro Morales

(oops, last comment was mine)

comment:6 Changed 8 years ago by Ramiro Morales

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

Changed 8 years ago by Ramiro Morales

screenshot showing problem with changelist field

Changed 8 years ago by Ramiro Morales

Attachment: list_filter_bug.png added

screenshot showing problem with list_filter section

Changed 8 years ago by Ramiro Morales

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

comment:7 Changed 8 years ago by Joshua Cender

Cc: Joshua Cender added

comment:8 Changed 8 years ago by Jacob

milestone: 1.1
Triage Stage: UnreviewedAccepted

Changed 7 years ago by Ramiro Morales

Patch updated to apply cleanly to trunk as of r10283

comment:9 Changed 7 years ago by Alex Gaynor

Triage Stage: AcceptedReady for checkin

comment:10 Changed 7 years ago by Alex Gaynor

Resolution: fixed
Status: newclosed

Fixed in r10318.

Changed 7 years ago by Ramiro Morales

Attachment: 9969-backport-to-1.0.x.diff added

Patch backported to 1.0.X branch

comment:11 Changed 7 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 5 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

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