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
69b0ac52
Commit
69b0ac52
authored
May 04, 2017
by
Tom Christie
Committed by
GitHub
May 04, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5117 from rpkilby/fix-filter-backend
Fix DjangoFilterBackend mro
parents
36aea309
01ffb896
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
5 deletions
+23
-5
requirements/requirements-optionals.txt
+1
-1
rest_framework/filters.py
+7
-4
tests/test_filters.py
+15
-0
No files found.
requirements/requirements-optionals.txt
View file @
69b0ac52
# Optional packages which may be used with REST framework.
# Optional packages which may be used with REST framework.
markdown==2.6.4
markdown==2.6.4
django-guardian==1.4.8
django-guardian==1.4.8
django-filter==1.0.
0
django-filter==1.0.
2
coreapi==2.2.4
coreapi==2.2.4
coreschema==0.0.4
coreschema==0.0.4
rest_framework/filters.py
View file @
69b0ac52
...
@@ -50,12 +50,17 @@ if django_filters:
...
@@ -50,12 +50,17 @@ if django_filters:
DeprecationWarning
DeprecationWarning
)
)
return
super
(
FilterSet
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
return
super
(
FilterSet
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
DFBase
=
django_filters
.
rest_framework
.
DjangoFilterBackend
else
:
else
:
def
FilterSet
():
def
FilterSet
():
assert
False
,
'django-filter must be installed to use the `FilterSet` class'
assert
False
,
'django-filter must be installed to use the `FilterSet` class'
DFBase
=
BaseFilterBackend
class
DjangoFilterBackend
(
BaseFilterBackend
):
class
DjangoFilterBackend
(
DFBase
):
"""
"""
A filter backend that uses django-filter.
A filter backend that uses django-filter.
"""
"""
...
@@ -69,9 +74,7 @@ class DjangoFilterBackend(BaseFilterBackend):
...
@@ -69,9 +74,7 @@ class DjangoFilterBackend(BaseFilterBackend):
DeprecationWarning
DeprecationWarning
)
)
from
django_filters.rest_framework
import
DjangoFilterBackend
return
super
(
DjangoFilterBackend
,
cls
)
.
__new__
(
cls
,
*
args
,
**
kwargs
)
return
DjangoFilterBackend
(
*
args
,
**
kwargs
)
class
SearchFilter
(
BaseFilterBackend
):
class
SearchFilter
(
BaseFilterBackend
):
...
...
tests/test_filters.py
View file @
69b0ac52
...
@@ -202,6 +202,21 @@ class IntegrationTestFiltering(CommonFilteringTestCase):
...
@@ -202,6 +202,21 @@ class IntegrationTestFiltering(CommonFilteringTestCase):
assert
len
(
w
)
==
0
assert
len
(
w
)
==
0
@unittest.skipUnless
(
django_filters
,
'django-filter not installed'
)
@unittest.skipUnless
(
django_filters
,
'django-filter not installed'
)
def
test_backend_mro
(
self
):
class
CustomBackend
(
filters
.
DjangoFilterBackend
):
def
filter_queryset
(
self
,
request
,
queryset
,
view
):
assert
False
,
"custom filter_queryset should run"
class
DFFilterFieldsRootView
(
FilterFieldsRootView
):
filter_backends
=
(
CustomBackend
,)
view
=
DFFilterFieldsRootView
.
as_view
()
request
=
factory
.
get
(
'/'
)
with
pytest
.
raises
(
AssertionError
,
message
=
"custom filter_queryset should run"
):
view
(
request
)
.
render
()
@unittest.skipUnless
(
django_filters
,
'django-filter not installed'
)
def
test_get_filtered_fields_root_view
(
self
):
def
test_get_filtered_fields_root_view
(
self
):
"""
"""
GET requests to paginated ListCreateAPIView should return paginated results.
GET requests to paginated ListCreateAPIView should return paginated results.
...
...
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