From 66cc2d3d5d611c57638a59932cd65c62d9b130c2 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 23 Dec 2013 12:37:56 +0000 Subject: Switch title ordering. --- tutorial/1-serialization.html | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'tutorial/1-serialization.html') diff --git a/tutorial/1-serialization.html b/tutorial/1-serialization.html index c75116d3..76c7f818 100644 --- a/tutorial/1-serialization.html +++ b/tutorial/1-serialization.html @@ -2,7 +2,7 @@ - Django REST framework - Tutorial 1: Serialization + Tutorial 1: Serialization - Django REST framework @@ -431,8 +431,7 @@ def snippet_list(request): if serializer.is_valid(): serializer.save() return JSONResponse(serializer.data, status=201) - else: - return JSONResponse(serializer.errors, status=400) + 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.

We'll also need a view which corresponds to an individual snippet, and can be used to retrieve, update or delete the snippet.

@@ -456,8 +455,7 @@ def snippet_detail(request, pk): if serializer.is_valid(): serializer.save() return JSONResponse(serializer.data) - else: - return JSONResponse(serializer.errors, status=400) + return JSONResponse(serializer.errors, status=400) elif request.method == 'DELETE': snippet.delete() -- cgit v1.2.3