From f02d346ec056e7fc6f2bb14244030e610da1aab5 Mon Sep 17 00:00:00 2001 From: Jeremy Langley Date: Mon, 28 Feb 2022 20:52:42 -0800 Subject: [PATCH] Update rest_framework/filters.py Co-authored-by: Tom Christie --- rest_framework/filters.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rest_framework/filters.py b/rest_framework/filters.py index d667a3826..e68726499 100644 --- a/rest_framework/filters.py +++ b/rest_framework/filters.py @@ -294,8 +294,10 @@ class OrderingFilter(BaseFilterBackend): 'param': self.ordering_param, } for key, label in self.get_valid_fields(queryset, view, context): - options.append((key, f'{label} - {_("ascending")}')) - options.append(('-' + key, f'{label} - {_("descending")}')) + ascending_translation = _("ascending") + descending_translation = _("descending") + options.append((key, f'{label} - {ascending_translation}')) + options.append(('-' + key, f'{label} - {descending_translation}')) context['options'] = options return context