From ee17cabba0e1f2cbb85b2044eda43108e3f4371c Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Wed, 1 Apr 2009 14:14:20 +0000 Subject: Fixed #9969: choices with options groups (added in [7977]) now work correctly in the admin with list_display and list_filter. Thanks, ramiro. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10318 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/filterspecs.py | 2 +- django/contrib/admin/templatetags/admin_list.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'django') diff --git a/django/contrib/admin/filterspecs.py b/django/contrib/admin/filterspecs.py index fd258df6b7..6f643ee102 100644 --- a/django/contrib/admin/filterspecs.py +++ b/django/contrib/admin/filterspecs.py @@ -90,7 +90,7 @@ class ChoicesFilterSpec(FilterSpec): yield {'selected': self.lookup_val is None, 'query_string': cl.get_query_string({}, [self.lookup_kwarg]), 'display': _('All')} - for k, v in self.field.choices: + for k, v in self.field.flatchoices: yield {'selected': smart_unicode(k) == self.lookup_val, 'query_string': cl.get_query_string({self.lookup_kwarg: k}), 'display': v} diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py index 21401caf43..d97c36a207 100644 --- a/django/contrib/admin/templatetags/admin_list.py +++ b/django/contrib/admin/templatetags/admin_list.py @@ -205,8 +205,8 @@ def items_for_result(cl, result, form): result_repr = EMPTY_CHANGELIST_VALUE # Fields with choices are special: Use the representation # of the choice. - elif f.choices: - result_repr = dict(f.choices).get(field_val, EMPTY_CHANGELIST_VALUE) + elif f.flatchoices: + result_repr = dict(f.flatchoices).get(field_val, EMPTY_CHANGELIST_VALUE) else: result_repr = escape(field_val) if force_unicode(result_repr) == '': -- cgit v1.3