55from __future__ import unicode_literals
66
77import operator
8- import warnings
98from functools import reduce
109
1110from django .core .exceptions import ImproperlyConfigured
1817from django .utils .translation import ugettext_lazy as _
1918
2019from rest_framework .compat import (
21- coreapi , coreschema , distinct , django_filters , guardian , template_render
20+ coreapi , coreschema , distinct , guardian , template_render
2221)
2322from rest_framework .settings import api_settings
2423
@@ -40,44 +39,6 @@ def get_schema_fields(self, view):
4039 return []
4140
4241
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-
8142class SearchFilter (BaseFilterBackend ):
8243 # The URL query parameter used for the search.
8344 search_param = api_settings .SEARCH_PARAM
0 commit comments