5
5
from __future__ import unicode_literals
6
6
7
7
import operator
8
- import warnings
9
8
from functools import reduce
10
9
11
10
from django .core .exceptions import ImproperlyConfigured
18
17
from django .utils .translation import ugettext_lazy as _
19
18
20
19
from rest_framework .compat import (
21
- coreapi , coreschema , distinct , django_filters , guardian , template_render
20
+ coreapi , coreschema , distinct , guardian , template_render
22
21
)
23
22
from rest_framework .settings import api_settings
24
23
@@ -40,44 +39,6 @@ def get_schema_fields(self, view):
40
39
return []
41
40
42
41
43
- if django_filters :
44
- from django_filters .rest_framework .filterset import FilterSet as DFFilterSet
45
-
46
- class FilterSet (DFFilterSet ):
47
- def __init__ (self , * args , ** kwargs ):
48
- warnings .warn (
49
- "The built in 'rest_framework.filters.FilterSet' is deprecated. "
50
- "You should use 'django_filters.rest_framework.FilterSet' instead." ,
51
- DeprecationWarning , stacklevel = 2
52
- )
53
- return super (FilterSet , self ).__init__ (* args , ** kwargs )
54
-
55
- DFBase = django_filters .rest_framework .DjangoFilterBackend
56
-
57
- else :
58
- def FilterSet ():
59
- assert False , 'django-filter must be installed to use the `FilterSet` class'
60
-
61
- DFBase = BaseFilterBackend
62
-
63
-
64
- class DjangoFilterBackend (DFBase ):
65
- """
66
- A filter backend that uses django-filter.
67
- """
68
- def __new__ (cls , * args , ** kwargs ):
69
- assert django_filters , 'Using DjangoFilterBackend, but django-filter is not installed'
70
- assert django_filters .VERSION >= (0 , 15 , 3 ), 'django-filter 0.15.3 and above is required'
71
-
72
- warnings .warn (
73
- "The built in 'rest_framework.filters.DjangoFilterBackend' is deprecated. "
74
- "You should use 'django_filters.rest_framework.DjangoFilterBackend' instead." ,
75
- DeprecationWarning , stacklevel = 2
76
- )
77
-
78
- return super (DjangoFilterBackend , cls ).__new__ (cls , * args , ** kwargs )
79
-
80
-
81
42
class SearchFilter (BaseFilterBackend ):
82
43
# The URL query parameter used for the search.
83
44
search_param = api_settings .SEARCH_PARAM
0 commit comments