Skip to content

Commit 8d72535

Browse files
authored
Fix FilterSet warnings. (#4660)
1 parent 06df61e commit 8d72535

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

rest_framework/filters.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,19 @@ def get_schema_fields(self, view):
3838

3939

4040
if django_filters:
41-
from django_filters.filterset import FilterSetMetaclass as DFFilterSetMetaclass
4241
from django_filters.rest_framework.filterset import FilterSet as DFFilterSet
4342

44-
class FilterSetMetaclass(DFFilterSetMetaclass):
45-
def __new__(cls, name, bases, attrs):
43+
class FilterSet(DFFilterSet):
44+
def __init__(self, *args, **kwargs):
4645
warnings.warn(
4746
"The built in 'rest_framework.filters.FilterSet' is pending deprecation. "
4847
"You should use 'django_filters.rest_framework.FilterSet' instead.",
4948
PendingDeprecationWarning
5049
)
51-
return super(FilterSetMetaclass, cls).__new__(cls, name, bases, attrs)
52-
_BaseFilterSet = DFFilterSet
50+
return super(FilterSet, self).__init__(*args, **kwargs)
5351
else:
54-
# Dummy metaclass just so we can give a user-friendly error message.
55-
class FilterSetMetaclass(type):
56-
def __init__(self, name, bases, attrs):
57-
# Assert only on subclasses, so we can define FilterSet below.
58-
if bases != (object,):
59-
assert False, 'django-filter must be installed to use the `FilterSet` class'
60-
super(FilterSetMetaclass, self).__init__(name, bases, attrs)
61-
_BaseFilterSet = object
62-
63-
64-
class FilterSet(six.with_metaclass(FilterSetMetaclass, _BaseFilterSet)):
65-
pass
52+
def FilterSet():
53+
assert False, 'django-filter must be installed to use the `FilterSet` class'
6654

6755

6856
class DjangoFilterBackend(BaseFilterBackend):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy