mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-02 20:54:42 +03:00
Copy filter_backends class attribute before returning it.
This commit is contained in:
parent
8244c7cc33
commit
9f3c7e8930
|
@ -189,7 +189,13 @@ class GenericAPIView(views.APIView):
|
||||||
"""
|
"""
|
||||||
Returns the list of filter backends that this view requires.
|
Returns the list of filter backends that this view requires.
|
||||||
"""
|
"""
|
||||||
filter_backends = self.filter_backends or []
|
if self.filter_backends is None:
|
||||||
|
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:
|
if not filter_backends and self.filter_backend:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'The `filter_backend` attribute and `FILTER_BACKEND` setting '
|
'The `filter_backend` attribute and `FILTER_BACKEND` setting '
|
||||||
|
@ -199,6 +205,7 @@ class GenericAPIView(views.APIView):
|
||||||
PendingDeprecationWarning, stacklevel=2
|
PendingDeprecationWarning, stacklevel=2
|
||||||
)
|
)
|
||||||
filter_backends = [self.filter_backend]
|
filter_backends = [self.filter_backend]
|
||||||
|
|
||||||
return filter_backends
|
return filter_backends
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user