mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 17:09:59 +03:00
Fix: default value as argument.
This commit is contained in:
parent
2664e65019
commit
20c1acf4c4
|
@ -203,9 +203,12 @@ class OrderingFilter(BaseFilterBackend):
|
||||||
return (ordering,)
|
return (ordering,)
|
||||||
return ordering
|
return ordering
|
||||||
|
|
||||||
def get_default_valid_fields(self, queryset, view, context={}):
|
def get_default_valid_fields(self, queryset, view, context=None):
|
||||||
# If `ordering_fields` is not specified, then we determine a default
|
# If `ordering_fields` is not specified, then we determine a default
|
||||||
# based on the serializer class, if one exists on the view.
|
# based on the serializer class, if one exists on the view.
|
||||||
|
if context is None:
|
||||||
|
context = {}
|
||||||
|
|
||||||
if hasattr(view, 'get_serializer_class'):
|
if hasattr(view, 'get_serializer_class'):
|
||||||
try:
|
try:
|
||||||
serializer_class = view.get_serializer_class()
|
serializer_class = view.get_serializer_class()
|
||||||
|
@ -230,7 +233,10 @@ class OrderingFilter(BaseFilterBackend):
|
||||||
if not getattr(field, 'write_only', False) and not field.source == '*'
|
if not getattr(field, 'write_only', False) and not field.source == '*'
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_valid_fields(self, queryset, view, context={}):
|
def get_valid_fields(self, queryset, view, context=None):
|
||||||
|
if context is None:
|
||||||
|
context = {}
|
||||||
|
|
||||||
valid_fields = getattr(view, 'ordering_fields', self.ordering_fields)
|
valid_fields = getattr(view, 'ordering_fields', self.ordering_fields)
|
||||||
|
|
||||||
if valid_fields is None:
|
if valid_fields is None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user