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
07af4373
Commit
07af4373
authored
Apr 09, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaning up around bits of API that will be pending deprecation
parent
9bb1277e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
rest_framework/generics.py
+16
-6
No files found.
rest_framework/generics.py
View file @
07af4373
...
@@ -24,15 +24,17 @@ class GenericAPIView(views.APIView):
...
@@ -24,15 +24,17 @@ class GenericAPIView(views.APIView):
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
pagination_serializer_class
=
api_settings
.
DEFAULT_PAGINATION_SERIALIZER_CLASS
allow_empty
=
True
page_kwarg
=
'page'
page_kwarg
=
'page'
lookup_kwarg
=
'pk'
lookup_kwarg
=
'pk'
allow_empty
=
True
######################################
# These are all pending deprecation...
# Pending deprecation
model
=
None
model
=
None
model_serializer_class
=
api_settings
.
DEFAULT_MODEL_SERIALIZER_CLASS
model_serializer_class
=
api_settings
.
DEFAULT_MODEL_SERIALIZER_CLASS
pk_url_kwarg
=
'pk'
# Not provided in Django 1.3
pk_url_kwarg
=
'pk'
slug_url_kwarg
=
'slug'
# Not provided in Django 1.3
slug_url_kwarg
=
'slug'
slug_field
=
'slug'
slug_field
=
'slug'
def
get_serializer_context
(
self
):
def
get_serializer_context
(
self
):
...
@@ -90,7 +92,8 @@ class GenericAPIView(views.APIView):
...
@@ -90,7 +92,8 @@ class GenericAPIView(views.APIView):
"""
"""
Paginate a queryset.
Paginate a queryset.
"""
"""
paginator
=
paginator_class
(
queryset
,
page_size
,
allow_empty_first_page
=
self
.
allow_empty
)
paginator
=
paginator_class
(
queryset
,
page_size
,
allow_empty_first_page
=
self
.
allow_empty
)
page_kwarg
=
self
.
page_kwarg
page_kwarg
=
self
.
page_kwarg
page
=
self
.
kwargs
.
get
(
page_kwarg
)
or
self
.
request
.
GET
.
get
(
page_kwarg
)
or
1
page
=
self
.
kwargs
.
get
(
page_kwarg
)
or
self
.
request
.
GET
.
get
(
page_kwarg
)
or
1
try
:
try
:
...
@@ -118,6 +121,7 @@ class GenericAPIView(views.APIView):
...
@@ -118,6 +121,7 @@ class GenericAPIView(views.APIView):
backend
=
self
.
filter_backend
()
backend
=
self
.
filter_backend
()
return
backend
.
filter_queryset
(
self
.
request
,
queryset
,
self
)
return
backend
.
filter_queryset
(
self
.
request
,
queryset
,
self
)
########################
### The following methods provide default implementations
### The following methods provide default implementations
### that you may want to override for more complex cases.
### that you may want to override for more complex cases.
...
@@ -204,7 +208,9 @@ class GenericAPIView(views.APIView):
...
@@ -204,7 +208,9 @@ class GenericAPIView(views.APIView):
return
obj
return
obj
### The following methods are intended to be overridden.
########################
### The following are placeholder methods,
### and are intended to be overridden.
def
pre_save
(
self
,
obj
):
def
pre_save
(
self
,
obj
):
"""
"""
...
@@ -222,8 +228,10 @@ class GenericAPIView(views.APIView):
...
@@ -222,8 +228,10 @@ class GenericAPIView(views.APIView):
pass
pass
##########################################################
### Concrete view classes that provide method handlers ###
### Concrete view classes that provide method handlers ###
### by composing the mixin classes with the base view. ###
### by composing the mixin classes with the base view. ###
##########################################################
class
CreateAPIView
(
mixins
.
CreateModelMixin
,
class
CreateAPIView
(
mixins
.
CreateModelMixin
,
GenericAPIView
):
GenericAPIView
):
...
@@ -338,7 +346,9 @@ class RetrieveUpdateDestroyAPIView(mixins.RetrieveModelMixin,
...
@@ -338,7 +346,9 @@ class RetrieveUpdateDestroyAPIView(mixins.RetrieveModelMixin,
return
self
.
destroy
(
request
,
*
args
,
**
kwargs
)
return
self
.
destroy
(
request
,
*
args
,
**
kwargs
)
##########################
### Deprecated classes ###
### Deprecated classes ###
##########################
class
MultipleObjectAPIView
(
GenericAPIView
):
class
MultipleObjectAPIView
(
GenericAPIView
):
pass
pass
...
...
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