Commit f6c19e5e by Ryan P Kilby Committed by Carlton Gibson

Remove DjangoFilterBackend and associated tests

parent cb6e7e0f
...@@ -182,13 +182,6 @@ except ImportError: ...@@ -182,13 +182,6 @@ except ImportError:
coreschema = None coreschema = None
# django-filter is optional
try:
import django_filters
except ImportError:
django_filters = None
# django-crispy-forms is optional # django-crispy-forms is optional
try: try:
import crispy_forms import crispy_forms
......
...@@ -5,7 +5,6 @@ returned by list views. ...@@ -5,7 +5,6 @@ returned by list views.
from __future__ import unicode_literals from __future__ import unicode_literals
import operator import operator
import warnings
from functools import reduce from functools import reduce
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
...@@ -18,7 +17,7 @@ from django.utils.encoding import force_text ...@@ -18,7 +17,7 @@ from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from rest_framework.compat import ( from rest_framework.compat import (
coreapi, coreschema, distinct, django_filters, guardian, template_render coreapi, coreschema, distinct, guardian, template_render
) )
from rest_framework.settings import api_settings from rest_framework.settings import api_settings
...@@ -40,44 +39,6 @@ class BaseFilterBackend(object): ...@@ -40,44 +39,6 @@ class BaseFilterBackend(object):
return [] return []
if django_filters:
from django_filters.rest_framework.filterset import FilterSet as DFFilterSet
class FilterSet(DFFilterSet):
def __init__(self, *args, **kwargs):
warnings.warn(
"The built in 'rest_framework.filters.FilterSet' is deprecated. "
"You should use 'django_filters.rest_framework.FilterSet' instead.",
DeprecationWarning, stacklevel=2
)
return super(FilterSet, self).__init__(*args, **kwargs)
DFBase = django_filters.rest_framework.DjangoFilterBackend
else:
def FilterSet():
assert False, 'django-filter must be installed to use the `FilterSet` class'
DFBase = BaseFilterBackend
class DjangoFilterBackend(DFBase):
"""
A filter backend that uses django-filter.
"""
def __new__(cls, *args, **kwargs):
assert django_filters, 'Using DjangoFilterBackend, but django-filter is not installed'
assert django_filters.VERSION >= (0, 15, 3), 'django-filter 0.15.3 and above is required'
warnings.warn(
"The built in 'rest_framework.filters.DjangoFilterBackend' is deprecated. "
"You should use 'django_filters.rest_framework.DjangoFilterBackend' instead.",
DeprecationWarning, stacklevel=2
)
return super(DjangoFilterBackend, cls).__new__(cls, *args, **kwargs)
class SearchFilter(BaseFilterBackend): class SearchFilter(BaseFilterBackend):
# The URL query parameter used for the search. # The URL query parameter used for the search.
search_param = api_settings.SEARCH_PARAM search_param = api_settings.SEARCH_PARAM
......
...@@ -24,15 +24,6 @@ class BasicModel(RESTFrameworkModel): ...@@ -24,15 +24,6 @@ class BasicModel(RESTFrameworkModel):
) )
class BaseFilterableItem(RESTFrameworkModel):
text = models.CharField(max_length=100)
class FilterableItem(BaseFilterableItem):
decimal = models.DecimalField(max_digits=4, decimal_places=2)
date = models.DateField()
# Models for relations tests # Models for relations tests
# ManyToMany # ManyToMany
class ManyToManyTarget(RESTFrameworkModel): class ManyToManyTarget(RESTFrameworkModel):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment