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
acbe9912
Commit
acbe9912
authored
Nov 16, 2012
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tidying
parent
016ef501
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
rest_framework/generics.py
+10
-4
No files found.
rest_framework/generics.py
View file @
acbe9912
...
@@ -14,6 +14,7 @@ class GenericAPIView(views.APIView):
...
@@ -14,6 +14,7 @@ class GenericAPIView(views.APIView):
"""
"""
Base class for all other generic views.
Base class for all other generic views.
"""
"""
model
=
None
model
=
None
serializer_class
=
None
serializer_class
=
None
model_serializer_class
=
api_settings
.
DEFAULT_MODEL_SERIALIZER_CLASS
model_serializer_class
=
api_settings
.
DEFAULT_MODEL_SERIALIZER_CLASS
...
@@ -47,7 +48,10 @@ class GenericAPIView(views.APIView):
...
@@ -47,7 +48,10 @@ class GenericAPIView(views.APIView):
return
serializer_class
return
serializer_class
def
get_serializer
(
self
,
instance
=
None
,
data
=
None
,
files
=
None
):
def
get_serializer
(
self
,
instance
=
None
,
data
=
None
,
files
=
None
):
# TODO: add support for seperate serializer/deserializer
"""
Return the serializer instance that should be used for validating and
deserializing input, and for serializing output.
"""
serializer_class
=
self
.
get_serializer_class
()
serializer_class
=
self
.
get_serializer_class
()
context
=
self
.
get_serializer_context
()
context
=
self
.
get_serializer_context
()
return
serializer_class
(
instance
,
data
=
data
,
files
=
files
,
context
=
context
)
return
serializer_class
(
instance
,
data
=
data
,
files
=
files
,
context
=
context
)
...
@@ -58,9 +62,9 @@ class MultipleObjectAPIView(MultipleObjectMixin, GenericAPIView):
...
@@ -58,9 +62,9 @@ class MultipleObjectAPIView(MultipleObjectMixin, GenericAPIView):
Base class for generic views onto a queryset.
Base class for generic views onto a queryset.
"""
"""
pagination_serializer_class
=
api_settings
.
DEFAULT_PAGINATION_SERIALIZER_CLASS
paginate_by
=
api_settings
.
PAGINATE_BY
paginate_by
=
api_settings
.
PAGINATE_BY
paginate_by_param
=
api_settings
.
PAGINATE_BY_PARAM
paginate_by_param
=
api_settings
.
PAGINATE_BY_PARAM
pagination_serializer_class
=
api_settings
.
DEFAULT_PAGINATION_SERIALIZER_CLASS
filter_backend
=
api_settings
.
FILTER_BACKEND
filter_backend
=
api_settings
.
FILTER_BACKEND
def
filter_queryset
(
self
,
queryset
):
def
filter_queryset
(
self
,
queryset
):
...
@@ -89,9 +93,9 @@ class MultipleObjectAPIView(MultipleObjectMixin, GenericAPIView):
...
@@ -89,9 +93,9 @@ class MultipleObjectAPIView(MultipleObjectMixin, GenericAPIView):
Return the size of pages to use with pagination.
Return the size of pages to use with pagination.
"""
"""
if
self
.
paginate_by_param
:
if
self
.
paginate_by_param
:
params
=
self
.
request
.
QUERY_PARAMS
query_
params
=
self
.
request
.
QUERY_PARAMS
try
:
try
:
return
int
(
params
[
self
.
paginate_by_param
])
return
int
(
query_
params
[
self
.
paginate_by_param
])
except
(
KeyError
,
ValueError
):
except
(
KeyError
,
ValueError
):
pass
pass
return
self
.
paginate_by
return
self
.
paginate_by
...
@@ -101,8 +105,10 @@ class SingleObjectAPIView(SingleObjectMixin, GenericAPIView):
...
@@ -101,8 +105,10 @@ class SingleObjectAPIView(SingleObjectMixin, GenericAPIView):
"""
"""
Base class for generic views onto a model instance.
Base class for generic views onto a model instance.
"""
"""
pk_url_kwarg
=
'pk'
# Not provided in Django 1.3
pk_url_kwarg
=
'pk'
# Not provided in Django 1.3
slug_url_kwarg
=
'slug'
# Not provided in Django 1.3
slug_url_kwarg
=
'slug'
# Not provided in Django 1.3
slug_field
=
'slug'
def
get_object
(
self
,
queryset
=
None
):
def
get_object
(
self
,
queryset
=
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