mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 00:04:16 +03:00
parent
d8eb9e6d45
commit
f62c874ea9
|
@ -83,7 +83,6 @@ class GenericAPIView(views.APIView):
|
||||||
slug_url_kwarg = 'slug'
|
slug_url_kwarg = 'slug'
|
||||||
slug_field = 'slug'
|
slug_field = 'slug'
|
||||||
allow_empty = True
|
allow_empty = True
|
||||||
filter_backend = api_settings.FILTER_BACKEND
|
|
||||||
|
|
||||||
def get_serializer_context(self):
|
def get_serializer_context(self):
|
||||||
"""
|
"""
|
||||||
|
@ -191,24 +190,7 @@ class GenericAPIView(views.APIView):
|
||||||
"""
|
"""
|
||||||
Returns the list of filter backends that this view requires.
|
Returns the list of filter backends that this view requires.
|
||||||
"""
|
"""
|
||||||
if self.filter_backends is None:
|
return list(self.filter_backends)
|
||||||
filter_backends = []
|
|
||||||
else:
|
|
||||||
# Note that we are returning a *copy* of the class attribute,
|
|
||||||
# so that it is safe for the view to mutate it if needed.
|
|
||||||
filter_backends = list(self.filter_backends)
|
|
||||||
|
|
||||||
if not filter_backends and self.filter_backend:
|
|
||||||
warnings.warn(
|
|
||||||
'The `filter_backend` attribute and `FILTER_BACKEND` setting '
|
|
||||||
'are deprecated in favor of a `filter_backends` '
|
|
||||||
'attribute and `DEFAULT_FILTER_BACKENDS` setting, that take '
|
|
||||||
'a *list* of filter backend classes.',
|
|
||||||
DeprecationWarning, stacklevel=2
|
|
||||||
)
|
|
||||||
filter_backends = [self.filter_backend]
|
|
||||||
|
|
||||||
return filter_backends
|
|
||||||
|
|
||||||
# The following methods provide default implementations
|
# The following methods provide default implementations
|
||||||
# that you may want to override for more complex cases.
|
# that you may want to override for more complex cases.
|
||||||
|
|
|
@ -111,9 +111,6 @@ DEFAULTS = {
|
||||||
),
|
),
|
||||||
'TIME_FORMAT': None,
|
'TIME_FORMAT': None,
|
||||||
|
|
||||||
# Pending deprecation
|
|
||||||
'FILTER_BACKEND': None,
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,7 +126,6 @@ IMPORT_STRINGS = (
|
||||||
'DEFAULT_PAGINATION_SERIALIZER_CLASS',
|
'DEFAULT_PAGINATION_SERIALIZER_CLASS',
|
||||||
'DEFAULT_FILTER_BACKENDS',
|
'DEFAULT_FILTER_BACKENDS',
|
||||||
'EXCEPTION_HANDLER',
|
'EXCEPTION_HANDLER',
|
||||||
'FILTER_BACKEND',
|
|
||||||
'TEST_REQUEST_RENDERER_CLASSES',
|
'TEST_REQUEST_RENDERER_CLASSES',
|
||||||
'UNAUTHENTICATED_USER',
|
'UNAUTHENTICATED_USER',
|
||||||
'UNAUTHENTICATED_TOKEN',
|
'UNAUTHENTICATED_TOKEN',
|
||||||
|
@ -196,15 +192,9 @@ class APISettings(object):
|
||||||
if val and attr in self.import_strings:
|
if val and attr in self.import_strings:
|
||||||
val = perform_import(val, attr)
|
val = perform_import(val, attr)
|
||||||
|
|
||||||
self.validate_setting(attr, val)
|
|
||||||
|
|
||||||
# Cache the result
|
# Cache the result
|
||||||
setattr(self, attr, val)
|
setattr(self, attr, val)
|
||||||
return val
|
return val
|
||||||
|
|
||||||
def validate_setting(self, attr, val):
|
|
||||||
if attr == 'FILTER_BACKEND' and val is not None:
|
|
||||||
# Make sure we can initialize the class
|
|
||||||
val()
|
|
||||||
|
|
||||||
api_settings = APISettings(USER_SETTINGS, DEFAULTS, IMPORT_STRINGS)
|
api_settings = APISettings(USER_SETTINGS, DEFAULTS, IMPORT_STRINGS)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user