aboutsummaryrefslogtreecommitdiffstats
path: root/tutorial/2-requests-and-responses.html
diff options
context:
space:
mode:
authorTom Christie2013-12-23 12:37:56 +0000
committerTom Christie2013-12-23 12:37:56 +0000
commit66cc2d3d5d611c57638a59932cd65c62d9b130c2 (patch)
tree9856f0c766c51f45e753dd8a6c01844879c5c0b4 /tutorial/2-requests-and-responses.html
parente6fd79fd88067d830886f9c463d5b9e5c13d7ce3 (diff)
downloaddjango-rest-framework-66cc2d3d5d611c57638a59932cd65c62d9b130c2.tar.bz2
Switch title ordering.
Diffstat (limited to 'tutorial/2-requests-and-responses.html')
-rw-r--r--tutorial/2-requests-and-responses.html8
1 files changed, 3 insertions, 5 deletions
diff --git a/tutorial/2-requests-and-responses.html b/tutorial/2-requests-and-responses.html
index 6b5f67da..ef821cec 100644
--- a/tutorial/2-requests-and-responses.html
+++ b/tutorial/2-requests-and-responses.html
@@ -2,7 +2,7 @@
<html lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
- <title>Django REST framework - Tutorial 2: Requests and Responses</title>
+ <title>Tutorial 2: Requests and Responses - Django REST framework</title>
<link href="http://django-rest-framework.org/img/favicon.ico" rel="icon" type="image/x-icon">
<link rel="canonical" href="http://django-rest-framework.org/tutorial/2-requests-and-responses"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -255,8 +255,7 @@ def snippet_list(request):
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
- else:
- return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
</code></pre>
<p>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.</p>
<p>Here is the view for an individual snippet, in the <code>views.py</code> module.</p>
@@ -279,8 +278,7 @@ def snippet_detail(request, pk):
if serializer.is_valid():
serializer.save()
return Response(serializer.data)
- else:
- return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
elif request.method == 'DELETE':
snippet.delete()