mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-30 18:09:59 +03:00
Fix get_default_valid_fields of OrderingFilter
This commit is contained in:
parent
a163c51238
commit
62113a794a
|
@ -226,10 +226,17 @@ class OrderingFilter(BaseFilterBackend):
|
||||||
)
|
)
|
||||||
raise ImproperlyConfigured(msg % self.__class__.__name__)
|
raise ImproperlyConfigured(msg % self.__class__.__name__)
|
||||||
|
|
||||||
|
model_field_names = [field.name for field in queryset.model._meta.fields]
|
||||||
|
|
||||||
return [
|
return [
|
||||||
(field.source.replace('.', '__') or field_name, field.label)
|
(field.source.replace('.', '__') or field_name, field.label)
|
||||||
for field_name, field in serializer_class(context=context).fields.items()
|
for field_name, field in serializer_class(context=context).fields.items()
|
||||||
if not getattr(field, 'write_only', False) and not field.source == '*'
|
if (
|
||||||
|
not getattr(field, 'write_only', False) and
|
||||||
|
not field.source == '*' and (
|
||||||
|
field_name in model_field_names or field.source in model_field_names
|
||||||
|
)
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_valid_fields(self, queryset, view, context={}):
|
def get_valid_fields(self, queryset, view, context={}):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user