From fc4bad4e407dcad2d9d826b981c00c2e3b715a0b Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Wed, 9 Aug 2017 08:18:36 -0400 Subject: [PATCH] Remove OrderingFilter.help_text (#757) * Remove confusing help text for OrderingFilter * Add OrderingFilter/SelectMultiple incompat note --- django_filters/filters.py | 1 + docs/ref/filters.txt | 3 ++- tests/test_filters.py | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/django_filters/filters.py b/django_filters/filters.py index ec16d4cb7..975333e64 100644 --- a/django_filters/filters.py +++ b/django_filters/filters.py @@ -618,6 +618,7 @@ def __init__(self, *args, **kwargs): kwargs['choices'] = self.build_choices(fields, field_labels) kwargs.setdefault('label', _('Ordering')) + kwargs.setdefault('help_text', '') kwargs.setdefault('null_label', None) super(OrderingFilter, self).__init__(*args, **kwargs) diff --git a/docs/ref/filters.txt b/docs/ref/filters.txt index 54a396705..062a2424e 100644 --- a/docs/ref/filters.txt +++ b/docs/ref/filters.txt @@ -757,7 +757,8 @@ want to disable descending sort options. This filter is also CSV-based, and accepts multiple ordering params. The default select widget does not enable the use of this, but it is useful -for APIs. +for APIs. ``SelectMultiple`` widgets are not compatible, given that they +are not able to retain selection order. Adding Custom filter choices """""""""""""""""""""""""""" diff --git a/tests/test_filters.py b/tests/test_filters.py index b946575d5..603f3ec02 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -1411,3 +1411,8 @@ def test_translation_override_label(self): ('username', 'BLABLA'), ('-username', 'BLABLA (malejÄ…co)'), ]) + + def test_help_text(self): + # regression test for #756 - the ususal CSV help_text is not relevant to ordering filters. + self.assertEqual(OrderingFilter().field.help_text, '') + self.assertEqual(OrderingFilter(help_text='a').field.help_text, 'a')