Skip to content

Commit f6c19e5

Browse files
Ryan P KilbyCarlton Gibson
authored andcommitted
Remove DjangoFilterBackend and associated tests
1 parent cb6e7e0 commit f6c19e5

File tree

4 files changed

+2
-479
lines changed

4 files changed

+2
-479
lines changed

rest_framework/compat.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,6 @@ def value_from_object(field, obj):
182182
coreschema = None
183183

184184

185-
# django-filter is optional
186-
try:
187-
import django_filters
188-
except ImportError:
189-
django_filters = None
190-
191-
192185
# django-crispy-forms is optional
193186
try:
194187
import crispy_forms

rest_framework/filters.py

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from __future__ import unicode_literals
66

77
import operator
8-
import warnings
98
from functools import reduce
109

1110
from django.core.exceptions import ImproperlyConfigured
@@ -18,7 +17,7 @@
1817
from django.utils.translation import ugettext_lazy as _
1918

2019
from rest_framework.compat import (
21-
coreapi, coreschema, distinct, django_filters, guardian, template_render
20+
coreapi, coreschema, distinct, guardian, template_render
2221
)
2322
from 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-
8142
class SearchFilter(BaseFilterBackend):
8243
# The URL query parameter used for the search.
8344
search_param = api_settings.SEARCH_PARAM

tests/models.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@ class BasicModel(RESTFrameworkModel):
2424
)
2525

2626

27-
class BaseFilterableItem(RESTFrameworkModel):
28-
text = models.CharField(max_length=100)
29-
30-
31-
class FilterableItem(BaseFilterableItem):
32-
decimal = models.DecimalField(max_digits=4, decimal_places=2)
33-
date = models.DateField()
34-
35-
3627
# Models for relations tests
3728
# ManyToMany
3829
class ManyToManyTarget(RESTFrameworkModel):

0 commit comments

Comments
 (0)