diff options
| author | amatellanes | 2013-12-23 08:56:34 +0100 |
|---|---|---|
| committer | amatellanes | 2013-12-23 08:56:34 +0100 |
| commit | 74f1cf635536ea99937954a11fa11531a832ebc2 (patch) | |
| tree | 2a728f85b59d30e38e7b4f416738e9b30e2ea2af /docs/tutorial/2-requests-and-responses.md | |
| parent | d6806340e54408858da4b2dc991be99edd65df76 (diff) | |
| download | django-rest-framework-74f1cf635536ea99937954a11fa11531a832ebc2.tar.bz2 | |
Revert "Simplified some examples in tutorial"
This reverts commit d6806340e54408858da4b2dc991be99edd65df76.
Diffstat (limited to 'docs/tutorial/2-requests-and-responses.md')
| -rw-r--r-- | docs/tutorial/2-requests-and-responses.md | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/docs/tutorial/2-requests-and-responses.md b/docs/tutorial/2-requests-and-responses.md index 603edd08..7fa4f3e4 100644 --- a/docs/tutorial/2-requests-and-responses.md +++ b/docs/tutorial/2-requests-and-responses.md @@ -59,7 +59,8 @@ We don't need our `JSONResponse` class in `views.py` anymore, so go ahead and de if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) + else: + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) Our instance view is an improvement over the previous example. It's a little more concise, and the code now feels very similar to if we were working with the Forms API. We're also using named status codes, which makes the response meanings more obvious. @@ -84,7 +85,8 @@ Here is the view for an individual snippet, in the `views.py` module. if serializer.is_valid(): serializer.save() return Response(serializer.data) - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) + else: + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) elif request.method == 'DELETE': snippet.delete() |
