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
ba7dca89
Commit
ba7dca89
authored
Jan 29, 2015
by
Tymur Maryokhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed router check for deprecated '.model' attribute
parent
60a63ffd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
11 deletions
+6
-11
rest_framework/routers.py
+2
-8
tests/test_routers.py
+4
-3
No files found.
rest_framework/routers.py
View file @
ba7dca89
...
...
@@ -130,19 +130,13 @@ class SimpleRouter(BaseRouter):
If `base_name` is not specified, attempt to automatically determine
it from the viewset.
"""
# Note that `.model` attribute on views is deprecated, although we
# enforce the deprecation on the view `get_serializer_class()` and
# `get_queryset()` methods, rather than here.
model_cls
=
getattr
(
viewset
,
'model'
,
None
)
queryset
=
getattr
(
viewset
,
'queryset'
,
None
)
if
model_cls
is
None
and
queryset
is
not
None
:
model_cls
=
queryset
.
model
assert
model_cls
,
'`base_name` argument not specified, and could '
\
assert
queryset
is
not
None
,
'`base_name` argument not specified, and could '
\
'not automatically determine the name from the viewset, as '
\
'it does not have a `.queryset` attribute.'
return
model_cls
.
_meta
.
object_name
.
lower
()
return
queryset
.
model
.
_meta
.
object_name
.
lower
()
def
get_routes
(
self
,
viewset
):
"""
...
...
tests/test_routers.py
View file @
ba7dca89
...
...
@@ -180,7 +180,7 @@ class TestLookupValueRegex(TestCase):
class
TestTrailingSlashIncluded
(
TestCase
):
def
setUp
(
self
):
class
NoteViewSet
(
viewsets
.
ModelViewSet
):
model
=
RouterTestModel
queryset
=
RouterTestModel
.
objects
.
all
()
self
.
router
=
SimpleRouter
()
self
.
router
.
register
(
r'notes'
,
NoteViewSet
)
...
...
@@ -195,7 +195,7 @@ class TestTrailingSlashIncluded(TestCase):
class
TestTrailingSlashRemoved
(
TestCase
):
def
setUp
(
self
):
class
NoteViewSet
(
viewsets
.
ModelViewSet
):
model
=
RouterTestModel
queryset
=
RouterTestModel
.
objects
.
all
()
self
.
router
=
SimpleRouter
(
trailing_slash
=
False
)
self
.
router
.
register
(
r'notes'
,
NoteViewSet
)
...
...
@@ -210,7 +210,8 @@ class TestTrailingSlashRemoved(TestCase):
class
TestNameableRoot
(
TestCase
):
def
setUp
(
self
):
class
NoteViewSet
(
viewsets
.
ModelViewSet
):
model
=
RouterTestModel
queryset
=
RouterTestModel
.
objects
.
all
()
self
.
router
=
DefaultRouter
()
self
.
router
.
root_view_name
=
'nameable-root'
self
.
router
.
register
(
r'notes'
,
NoteViewSet
)
...
...
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