Update rest_framework/filters.py

Co-authored-by: Tom Christie <tom@tomchristie.com>
This commit is contained in:
Jeremy Langley 2022-02-28 20:52:42 -08:00 committed by GitHub
parent 3ff562030c
commit f02d346ec0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -294,8 +294,10 @@ class OrderingFilter(BaseFilterBackend):
'param': self.ordering_param, 'param': self.ordering_param,
} }
for key, label in self.get_valid_fields(queryset, view, context): for key, label in self.get_valid_fields(queryset, view, context):
options.append((key, f'{label} - {_("ascending")}')) ascending_translation = _("ascending")
options.append(('-' + key, f'{label} - {_("descending")}')) descending_translation = _("descending")
options.append((key, f'{label} - {ascending_translation}'))
options.append(('-' + key, f'{label} - {descending_translation}'))
context['options'] = options context['options'] = options
return context return context