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
f54fc3a7
Commit
f54fc3a7
authored
Aug 23, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/tomchristie/django-rest-framework
parents
f2b190e3
7bbe0f86
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
5 deletions
+23
-5
docs/topics/credits.md
+2
-0
rest_framework/mixins.py
+10
-5
rest_framework/tests/test_generics.py
+11
-0
No files found.
docs/topics/credits.md
View file @
f54fc3a7
...
@@ -160,6 +160,7 @@ The following people have helped make REST framework great.
...
@@ -160,6 +160,7 @@ The following people have helped make REST framework great.
*
Christopher Paolini -
[
chrispaolini
]
*
Christopher Paolini -
[
chrispaolini
]
*
Filipe A Ximenes -
[
filipeximenes
]
*
Filipe A Ximenes -
[
filipeximenes
]
*
Ramiro Morales -
[
ramiro
]
*
Ramiro Morales -
[
ramiro
]
*
Krzysztof Jurewicz -
[
krzysiekj
]
Many thanks to everyone who's contributed to the project.
Many thanks to everyone who's contributed to the project.
...
@@ -356,3 +357,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter.
...
@@ -356,3 +357,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter.
[
chrispaolini
]:
https://github.com/chrispaolini
[
chrispaolini
]:
https://github.com/chrispaolini
[
filipeximenes
]:
https://github.com/filipeximenes
[
filipeximenes
]:
https://github.com/filipeximenes
[
ramiro
]:
https://github.com/ramiro
[
ramiro
]:
https://github.com/ramiro
[
krzysiekj
]:
https://github.com/krzysiekj
rest_framework/mixins.py
View file @
f54fc3a7
...
@@ -142,11 +142,16 @@ class UpdateModelMixin(object):
...
@@ -142,11 +142,16 @@ class UpdateModelMixin(object):
try
:
try
:
return
self
.
get_object
()
return
self
.
get_object
()
except
Http404
:
except
Http404
:
# If this is a PUT-as-create operation, we need to ensure that
if
self
.
request
.
method
==
'PUT'
:
# we have relevant permissions, as if this was a POST request.
# For PUT-as-create operation, we need to ensure that we have
# This will either raise a PermissionDenied exception,
# relevant permissions, as if this was a POST request. This
# or simply return None
# will either raise a PermissionDenied exception, or simply
self
.
check_permissions
(
clone_request
(
self
.
request
,
'POST'
))
# return None.
self
.
check_permissions
(
clone_request
(
self
.
request
,
'POST'
))
else
:
# PATCH requests where the object does not exist should still
# return a 404 response.
raise
def
pre_save
(
self
,
obj
):
def
pre_save
(
self
,
obj
):
"""
"""
...
...
rest_framework/tests/test_generics.py
View file @
f54fc3a7
...
@@ -338,6 +338,17 @@ class TestInstanceView(TestCase):
...
@@ -338,6 +338,17 @@ class TestInstanceView(TestCase):
new_obj
=
SlugBasedModel
.
objects
.
get
(
slug
=
'test_slug'
)
new_obj
=
SlugBasedModel
.
objects
.
get
(
slug
=
'test_slug'
)
self
.
assertEqual
(
new_obj
.
text
,
'foobar'
)
self
.
assertEqual
(
new_obj
.
text
,
'foobar'
)
def
test_patch_cannot_create_an_object
(
self
):
"""
PATCH requests should not be able to create objects.
"""
data
=
{
'text'
:
'foobar'
}
request
=
factory
.
patch
(
'/999'
,
data
,
format
=
'json'
)
with
self
.
assertNumQueries
(
1
):
response
=
self
.
view
(
request
,
pk
=
999
)
.
render
()
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_404_NOT_FOUND
)
self
.
assertFalse
(
self
.
objects
.
filter
(
id
=
999
)
.
exists
())
class
TestOverriddenGetObject
(
TestCase
):
class
TestOverriddenGetObject
(
TestCase
):
"""
"""
...
...
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