aboutsummaryrefslogtreecommitdiffstats
path: root/docs/tutorial/1-serialization.md
diff options
context:
space:
mode:
authoramatellanes2013-12-23 08:56:34 +0100
committeramatellanes2013-12-23 08:56:34 +0100
commit74f1cf635536ea99937954a11fa11531a832ebc2 (patch)
tree2a728f85b59d30e38e7b4f416738e9b30e2ea2af /docs/tutorial/1-serialization.md
parentd6806340e54408858da4b2dc991be99edd65df76 (diff)
downloaddjango-rest-framework-74f1cf635536ea99937954a11fa11531a832ebc2.tar.bz2
Revert "Simplified some examples in tutorial"
This reverts commit d6806340e54408858da4b2dc991be99edd65df76.
Diffstat (limited to 'docs/tutorial/1-serialization.md')
-rw-r--r--docs/tutorial/1-serialization.md6
1 files changed, 4 insertions, 2 deletions
diff --git a/docs/tutorial/1-serialization.md b/docs/tutorial/1-serialization.md
index 2298df59..e015a545 100644
--- a/docs/tutorial/1-serialization.md
+++ b/docs/tutorial/1-serialization.md
@@ -263,7 +263,8 @@ The root of our API is going to be a view that supports listing all the existing
if serializer.is_valid():
serializer.save()
return JSONResponse(serializer.data, status=201)
- return JSONResponse(serializer.errors, status=400)
+ else:
+ return JSONResponse(serializer.errors, status=400)
Note that because we want to be able to POST to this view from clients that won't have a CSRF token we need to mark the view as `csrf_exempt`. This isn't something that you'd normally want to do, and REST framework views actually use more sensible behavior than this, but it'll do for our purposes right now.
@@ -289,7 +290,8 @@ We'll also need a view which corresponds to an individual snippet, and can be us
if serializer.is_valid():
serializer.save()
return JSONResponse(serializer.data)
- return JSONResponse(serializer.errors, status=400)
+ else:
+ return JSONResponse(serializer.errors, status=400)
elif request.method == 'DELETE':
snippet.delete()