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
1de6cff1
Commit
1de6cff1
authored
Apr 09, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaning up get_object and get_queryset
parent
dc45bc7b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
13 deletions
+10
-13
rest_framework/generics.py
+10
-13
No files found.
rest_framework/generics.py
View file @
1de6cff1
...
@@ -148,25 +148,22 @@ class GenericAPIView(views.APIView):
...
@@ -148,25 +148,22 @@ class GenericAPIView(views.APIView):
def
get_queryset
(
self
):
def
get_queryset
(
self
):
"""
"""
Get the list of items for this view. This must be an iterable, and may
Get the list of items for this view.
be a queryset (in which qs-specific behavior will be enabled).
This must be an iterable, and may be a queryset.
"""
"""
if
self
.
queryset
is
not
None
:
if
self
.
queryset
is
not
None
:
queryset
=
self
.
queryset
return
self
.
queryset
.
_clone
()
if
hasattr
(
queryset
,
'_clone'
):
queryset
=
queryset
.
_clone
()
if
self
.
model
is
not
None
:
elif
self
.
model
is
not
None
:
return
self
.
model
.
_default_manager
.
all
()
queryset
=
self
.
model
.
_default_manager
.
all
()
else
:
raise
ImproperlyConfigured
(
"'
%
s' must define 'queryset' or 'model'"
raise
ImproperlyConfigured
(
"'
%
s' must define 'queryset' or 'model'"
%
self
.
__class__
.
__name__
)
%
self
.
__class__
.
__name__
)
return
queryset
def
get_object
(
self
,
queryset
=
None
):
def
get_object
(
self
,
queryset
=
None
):
"""
"""
Returns the object the view is displaying.
Returns the object the view is displaying.
By default this requires `self.queryset` and a `pk` or `slug` argument
in the URLconf, but subclasses can override this to return any object.
"""
"""
# Determine the base queryset to use.
# Determine the base queryset to use.
if
queryset
is
None
:
if
queryset
is
None
:
...
...
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