Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
f6c19e5e
Commit
f6c19e5e
authored
Jul 14, 2017
by
Ryan P Kilby
Committed by
Carlton Gibson
Sep 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove DjangoFilterBackend and associated tests
parent
cb6e7e0f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 additions
and
56 deletions
+1
-56
rest_framework/compat.py
+0
-7
rest_framework/filters.py
+1
-40
tests/models.py
+0
-9
tests/test_filters.py
+0
-0
No files found.
rest_framework/compat.py
View file @
f6c19e5e
...
@@ -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
...
...
rest_framework/filters.py
View file @
f6c19e5e
...
@@ -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
...
...
tests/models.py
View file @
f6c19e5e
...
@@ -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
):
...
...
tests/test_filters.py
View file @
f6c19e5e
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment