Update filters.py

This commit is contained in:
MeRuslan 2020-08-28 10:37:24 +03:00 committed by GitHub
parent 7f3a3557a0
commit a732d0f1a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -297,13 +297,18 @@ class OrderingFilter(BaseFilterBackend):
def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
# display aliases
ordering_choices = [fields[0] for fields in super().get_valid_fields(None, view)]
return [
coreapi.Field(
name=self.ordering_param,
required=False,
location='query',
schema=coreschema.String(
schema=coreschema.Enum(
title=force_str(self.ordering_title),
enum=ordering_choices,
description=force_str(self.ordering_description)
)
)