Ticket #15971: 15971.diff

File 15971.diff, 4.6 KB (added by Matthias Kestenholz, 14 years ago)
  • django/contrib/admin/filters.py

    diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py
    index c1fc979..0cd90e3 100644
    a b class FieldListFilter(ListFilter):  
    110110    def __init__(self, field, request, params, model, model_admin, field_path):
    111111        self.field = field
    112112        self.field_path = field_path
    113         self.title = field_path
     113        try:
     114            self.title = field.verbose_name
     115        except AttributeError:
     116            self.title = field.opts.verbose_name
    114117        super(FieldListFilter, self).__init__(request, params, model, model_admin)
    115118
    116119    def has_output(self):
  • tests/regressiontests/admin_filters/tests.py

    diff --git a/tests/regressiontests/admin_filters/tests.py b/tests/regressiontests/admin_filters/tests.py
    index 7717984..f5542dd 100644
    a b class ListFiltersTests(TestCase):  
    128128
    129129        # Make sure the correct choice is selected
    130130        filterspec = changelist.get_filters(request)[0][4]
    131         self.assertEqual(force_unicode(filterspec.title), u'date_registered')
     131        self.assertEqual(force_unicode(filterspec.title), u'date registered')
    132132        choice = select_by(filterspec.choices(changelist), "display", "Today")
    133133        self.assertEqual(choice['selected'], True)
    134134        self.assertEqual(choice['query_string'], '?date_registered__day=%s'
    class ListFiltersTests(TestCase):  
    150150
    151151        # Make sure the correct choice is selected
    152152        filterspec = changelist.get_filters(request)[0][4]
    153         self.assertEqual(force_unicode(filterspec.title), u'date_registered')
     153        self.assertEqual(force_unicode(filterspec.title), u'date registered')
    154154        choice = select_by(filterspec.choices(changelist), "display", "This month")
    155155        self.assertEqual(choice['selected'], True)
    156156        self.assertEqual(choice['query_string'], '?date_registered__month=%s'
    class ListFiltersTests(TestCase):  
    170170
    171171        # Make sure the correct choice is selected
    172172        filterspec = changelist.get_filters(request)[0][4]
    173         self.assertEqual(force_unicode(filterspec.title), u'date_registered')
     173        self.assertEqual(force_unicode(filterspec.title), u'date registered')
    174174        choice = select_by(filterspec.choices(changelist), "display", "This year")
    175175        self.assertEqual(choice['selected'], True)
    176176        self.assertEqual(choice['query_string'], '?date_registered__year=%s'
    class ListFiltersTests(TestCase):  
    186186
    187187        # Make sure the correct choice is selected
    188188        filterspec = changelist.get_filters(request)[0][4]
    189         self.assertEqual(force_unicode(filterspec.title), u'date_registered')
     189        self.assertEqual(force_unicode(filterspec.title), u'date registered')
    190190        choice = select_by(filterspec.choices(changelist), "display", "Past 7 days")
    191191        self.assertEqual(choice['selected'], True)
    192192        self.assertEqual(choice['query_string'], '?date_registered__gte=%s'
    class ListFiltersTests(TestCase):  
    349349
    350350        # Make sure the correct choice is selected
    351351        filterspec = changelist.get_filters(request)[0][3]
    352         self.assertEqual(force_unicode(filterspec.title), u'is_best_seller')
     352        self.assertEqual(force_unicode(filterspec.title), u'is best seller')
    353353        choice = select_by(filterspec.choices(changelist), "display", "No")
    354354        self.assertEqual(choice['selected'], True)
    355355        self.assertEqual(choice['query_string'], '?is_best_seller__exact=0')
    class ListFiltersTests(TestCase):  
    363363
    364364        # Make sure the correct choice is selected
    365365        filterspec = changelist.get_filters(request)[0][3]
    366         self.assertEqual(force_unicode(filterspec.title), u'is_best_seller')
     366        self.assertEqual(force_unicode(filterspec.title), u'is best seller')
    367367        choice = select_by(filterspec.choices(changelist), "display", "Yes")
    368368        self.assertEqual(choice['selected'], True)
    369369        self.assertEqual(choice['query_string'], '?is_best_seller__exact=1')
    class ListFiltersTests(TestCase):  
    377377
    378378        # Make sure the correct choice is selected
    379379        filterspec = changelist.get_filters(request)[0][3]
    380         self.assertEqual(force_unicode(filterspec.title), u'is_best_seller')
     380        self.assertEqual(force_unicode(filterspec.title), u'is best seller')
    381381        choice = select_by(filterspec.choices(changelist), "display", "Unknown")
    382382        self.assertEqual(choice['selected'], True)
    383383        self.assertEqual(choice['query_string'], '?is_best_seller__isnull=True')
Back to Top