From 66cc2d3d5d611c57638a59932cd65c62d9b130c2 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 23 Dec 2013 12:37:56 +0000 Subject: [PATCH] Switch title ordering. --- api-guide/authentication.html | 2 +- api-guide/content-negotiation.html | 2 +- api-guide/exceptions.html | 9 ++++++++- api-guide/fields.html | 2 +- api-guide/filtering.html | 2 +- api-guide/format-suffixes.html | 2 +- api-guide/generic-views.html | 2 +- api-guide/pagination.html | 2 +- api-guide/parsers.html | 2 +- api-guide/permissions.html | 2 +- api-guide/relations.html | 2 +- api-guide/renderers.html | 2 +- api-guide/requests.html | 2 +- api-guide/responses.html | 2 +- api-guide/reverse.html | 2 +- api-guide/routers.html | 2 +- api-guide/serializers.html | 2 +- api-guide/settings.html | 2 +- api-guide/status-codes.html | 2 +- api-guide/testing.html | 2 +- api-guide/throttling.html | 2 +- api-guide/views.html | 2 +- api-guide/viewsets.html | 2 +- topics/2.2-announcement.html | 2 +- topics/2.3-announcement.html | 2 +- topics/ajax-csrf-cors.html | 2 +- topics/browsable-api.html | 2 +- topics/browser-enhancements.html | 2 +- topics/contributing.html | 2 +- topics/credits.html | 2 +- topics/documenting-your-api.html | 2 +- topics/release-notes.html | 3 ++- topics/rest-framework-2-announcement.html | 2 +- topics/rest-hypermedia-hateoas.html | 2 +- topics/writable-nested-serializers.html | 2 +- tutorial/1-serialization.html | 8 +++----- tutorial/2-requests-and-responses.html | 8 +++----- tutorial/3-class-based-views.html | 2 +- tutorial/4-authentication-and-permissions.html | 6 +++--- tutorial/5-relationships-and-hyperlinked-apis.html | 2 +- tutorial/6-viewsets-and-routers.html | 2 +- tutorial/quickstart.html | 2 +- 42 files changed, 56 insertions(+), 52 deletions(-) diff --git a/api-guide/authentication.html b/api-guide/authentication.html index b07453590..3cefc3609 100644 --- a/api-guide/authentication.html +++ b/api-guide/authentication.html @@ -2,7 +2,7 @@ - Django REST framework - Authentication + Authentication - Django REST framework diff --git a/api-guide/content-negotiation.html b/api-guide/content-negotiation.html index 83157c1ed..8be70ee41 100644 --- a/api-guide/content-negotiation.html +++ b/api-guide/content-negotiation.html @@ -2,7 +2,7 @@ - Django REST framework - Content negotiation + Content negotiation - Django REST framework diff --git a/api-guide/exceptions.html b/api-guide/exceptions.html index 161a69e10..c83a6a6dd 100644 --- a/api-guide/exceptions.html +++ b/api-guide/exceptions.html @@ -2,7 +2,7 @@ - Django REST framework - Exceptions + Exceptions - Django REST framework @@ -279,6 +279,13 @@ def custom_exception_handler(exc):

Signature: APIException()

The base class for all exceptions raised inside REST framework.

To provide a custom exception, subclass APIException and set the .status_code and .detail properties on the class.

+

For example, if your API relies on a third party service that may sometimes be unreachable, you might want to implement an exception for the "503 Service Unavailable" HTTP response code. You could do this like so:

+
from rest_framework.exceptions import APIException
+
+class ServiceUnavailable(APIException):
+    status_code = 503
+    detail = 'Service temporarily unavailable, try again later.'
+

ParseError

Signature: ParseError(detail=None)

Raised if the request contains malformed data when accessing request.DATA or request.FILES.

diff --git a/api-guide/fields.html b/api-guide/fields.html index 405792e3e..6cbb7f12f 100644 --- a/api-guide/fields.html +++ b/api-guide/fields.html @@ -2,7 +2,7 @@ - Django REST framework - Serializer fields + Serializer fields - Django REST framework diff --git a/api-guide/filtering.html b/api-guide/filtering.html index 4921927a5..221ed1a7e 100644 --- a/api-guide/filtering.html +++ b/api-guide/filtering.html @@ -2,7 +2,7 @@ - Django REST framework - Filtering + Filtering - Django REST framework diff --git a/api-guide/format-suffixes.html b/api-guide/format-suffixes.html index 1b8cdae22..3137e7051 100644 --- a/api-guide/format-suffixes.html +++ b/api-guide/format-suffixes.html @@ -2,7 +2,7 @@ - Django REST framework - Format suffixes + Format suffixes - Django REST framework diff --git a/api-guide/generic-views.html b/api-guide/generic-views.html index df2368469..c90330fc9 100644 --- a/api-guide/generic-views.html +++ b/api-guide/generic-views.html @@ -2,7 +2,7 @@ - Django REST framework - Generic views + Generic views - Django REST framework diff --git a/api-guide/pagination.html b/api-guide/pagination.html index 9bbd9a473..bda2b457e 100644 --- a/api-guide/pagination.html +++ b/api-guide/pagination.html @@ -2,7 +2,7 @@ - Django REST framework - Pagination + Pagination - Django REST framework diff --git a/api-guide/parsers.html b/api-guide/parsers.html index 73e3539c9..c0ce8d604 100644 --- a/api-guide/parsers.html +++ b/api-guide/parsers.html @@ -2,7 +2,7 @@ - Django REST framework - Parsers + Parsers - Django REST framework diff --git a/api-guide/permissions.html b/api-guide/permissions.html index 575ab99e0..75275f32d 100644 --- a/api-guide/permissions.html +++ b/api-guide/permissions.html @@ -2,7 +2,7 @@ - Django REST framework - Permissions + Permissions - Django REST framework diff --git a/api-guide/relations.html b/api-guide/relations.html index 7b4056dbf..d774972d9 100644 --- a/api-guide/relations.html +++ b/api-guide/relations.html @@ -2,7 +2,7 @@ - Django REST framework - Serializer relations + Serializer relations - Django REST framework diff --git a/api-guide/renderers.html b/api-guide/renderers.html index c68fe2171..b98a27de1 100644 --- a/api-guide/renderers.html +++ b/api-guide/renderers.html @@ -2,7 +2,7 @@ - Django REST framework - Renderers + Renderers - Django REST framework diff --git a/api-guide/requests.html b/api-guide/requests.html index d0d5704d6..637534273 100644 --- a/api-guide/requests.html +++ b/api-guide/requests.html @@ -2,7 +2,7 @@ - Django REST framework - Requests + Requests - Django REST framework diff --git a/api-guide/responses.html b/api-guide/responses.html index 286d7bfd7..27a8d22d3 100644 --- a/api-guide/responses.html +++ b/api-guide/responses.html @@ -2,7 +2,7 @@ - Django REST framework - Responses + Responses - Django REST framework diff --git a/api-guide/reverse.html b/api-guide/reverse.html index 434b2fd08..7db25193a 100644 --- a/api-guide/reverse.html +++ b/api-guide/reverse.html @@ -2,7 +2,7 @@ - Django REST framework - Returning URLs + Returning URLs - Django REST framework diff --git a/api-guide/routers.html b/api-guide/routers.html index c4477541c..028314bc8 100644 --- a/api-guide/routers.html +++ b/api-guide/routers.html @@ -2,7 +2,7 @@ - Django REST framework - Routers + Routers - Django REST framework diff --git a/api-guide/serializers.html b/api-guide/serializers.html index ce04b3f31..70696b3a2 100644 --- a/api-guide/serializers.html +++ b/api-guide/serializers.html @@ -2,7 +2,7 @@ - Django REST framework - Serializers + Serializers - Django REST framework diff --git a/api-guide/settings.html b/api-guide/settings.html index 10f16a230..d9e493d97 100644 --- a/api-guide/settings.html +++ b/api-guide/settings.html @@ -2,7 +2,7 @@ - Django REST framework - Settings + Settings - Django REST framework diff --git a/api-guide/status-codes.html b/api-guide/status-codes.html index b6bfaadd9..18a31fb2b 100644 --- a/api-guide/status-codes.html +++ b/api-guide/status-codes.html @@ -2,7 +2,7 @@ - Django REST framework - Status Codes + Status Codes - Django REST framework diff --git a/api-guide/testing.html b/api-guide/testing.html index 2eae01498..eb8d668c9 100644 --- a/api-guide/testing.html +++ b/api-guide/testing.html @@ -2,7 +2,7 @@ - Django REST framework - Testing + Testing - Django REST framework diff --git a/api-guide/throttling.html b/api-guide/throttling.html index 8800a02d2..fc2dd14a4 100644 --- a/api-guide/throttling.html +++ b/api-guide/throttling.html @@ -2,7 +2,7 @@ - Django REST framework - Throttling + Throttling - Django REST framework diff --git a/api-guide/views.html b/api-guide/views.html index c63f47ba8..45828da80 100644 --- a/api-guide/views.html +++ b/api-guide/views.html @@ -2,7 +2,7 @@ - Django REST framework - Class Based Views + Class Based Views - Django REST framework diff --git a/api-guide/viewsets.html b/api-guide/viewsets.html index 5cd380799..f87afe9c0 100644 --- a/api-guide/viewsets.html +++ b/api-guide/viewsets.html @@ -2,7 +2,7 @@ - Django REST framework - ViewSets + ViewSets - Django REST framework diff --git a/topics/2.2-announcement.html b/topics/2.2-announcement.html index e76032ff3..0e0584f5d 100644 --- a/topics/2.2-announcement.html +++ b/topics/2.2-announcement.html @@ -2,7 +2,7 @@ - Django REST framework - REST framework 2.2 announcement + REST framework 2.2 announcement - Django REST framework diff --git a/topics/2.3-announcement.html b/topics/2.3-announcement.html index b22a136d3..76d384994 100644 --- a/topics/2.3-announcement.html +++ b/topics/2.3-announcement.html @@ -2,7 +2,7 @@ - Django REST framework - REST framework 2.3 announcement + REST framework 2.3 announcement - Django REST framework diff --git a/topics/ajax-csrf-cors.html b/topics/ajax-csrf-cors.html index cf33a56e6..0322d233e 100644 --- a/topics/ajax-csrf-cors.html +++ b/topics/ajax-csrf-cors.html @@ -2,7 +2,7 @@ - Django REST framework - Working with AJAX, CSRF & CORS + Working with AJAX, CSRF & CORS - Django REST framework diff --git a/topics/browsable-api.html b/topics/browsable-api.html index ba58eec00..2d86354d2 100644 --- a/topics/browsable-api.html +++ b/topics/browsable-api.html @@ -2,7 +2,7 @@ - Django REST framework - The Browsable API + The Browsable API - Django REST framework diff --git a/topics/browser-enhancements.html b/topics/browser-enhancements.html index 11b53d530..f92e2737e 100644 --- a/topics/browser-enhancements.html +++ b/topics/browser-enhancements.html @@ -2,7 +2,7 @@ - Django REST framework - Browser enhancements + Browser enhancements - Django REST framework diff --git a/topics/contributing.html b/topics/contributing.html index 986ff9244..9120285c6 100644 --- a/topics/contributing.html +++ b/topics/contributing.html @@ -2,7 +2,7 @@ - Django REST framework - Contributing to REST framework + Contributing to REST framework - Django REST framework diff --git a/topics/credits.html b/topics/credits.html index 533de8821..06a7819ce 100644 --- a/topics/credits.html +++ b/topics/credits.html @@ -2,7 +2,7 @@ - Django REST framework - Credits + Credits - Django REST framework diff --git a/topics/documenting-your-api.html b/topics/documenting-your-api.html index 1489fb4ec..29cdca4d1 100644 --- a/topics/documenting-your-api.html +++ b/topics/documenting-your-api.html @@ -2,7 +2,7 @@ - Django REST framework - Documenting your API + Documenting your API - Django REST framework diff --git a/topics/release-notes.html b/topics/release-notes.html index 2630aaa0a..36cc57525 100644 --- a/topics/release-notes.html +++ b/topics/release-notes.html @@ -2,7 +2,7 @@ - Django REST framework - Release Notes + Release Notes - Django REST framework @@ -250,6 +250,7 @@
  • Fix compatiblity with newer versions of django-oauth-plus.
  • Bugfix: Refine behavior that calls model manager all() across nested serializer relationships, preventing erronous behavior with some non-ORM objects, and preventing unneccessary queryset re-evaluations.
  • Bugfix: Allow defaults on BooleanFields to be properly honored when values are not supplied.
  • +
  • Bugfix: Prevent double-escaping of non-latin1 URL query params when appending format=json params.
  • 2.3.10

    Date: 6th December 2013

    diff --git a/topics/rest-framework-2-announcement.html b/topics/rest-framework-2-announcement.html index ebee8822b..eed36c724 100644 --- a/topics/rest-framework-2-announcement.html +++ b/topics/rest-framework-2-announcement.html @@ -2,7 +2,7 @@ - Django REST framework - Django REST framework 2 + Django REST framework 2 - Django REST framework diff --git a/topics/rest-hypermedia-hateoas.html b/topics/rest-hypermedia-hateoas.html index 176cfbf35..63a9921ba 100644 --- a/topics/rest-hypermedia-hateoas.html +++ b/topics/rest-hypermedia-hateoas.html @@ -2,7 +2,7 @@ - Django REST framework - REST, Hypermedia & HATEOAS + REST, Hypermedia & HATEOAS - Django REST framework diff --git a/topics/writable-nested-serializers.html b/topics/writable-nested-serializers.html index 0a10ce99b..32653db46 100644 --- a/topics/writable-nested-serializers.html +++ b/topics/writable-nested-serializers.html @@ -2,7 +2,7 @@ - Django REST framework - Writable nested serializers + Writable nested serializers - Django REST framework diff --git a/tutorial/1-serialization.html b/tutorial/1-serialization.html index c75116d3f..76c7f818a 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() diff --git a/tutorial/2-requests-and-responses.html b/tutorial/2-requests-and-responses.html index 6b5f67da9..ef821cec8 100644 --- a/tutorial/2-requests-and-responses.html +++ b/tutorial/2-requests-and-responses.html @@ -2,7 +2,7 @@ - Django REST framework - Tutorial 2: Requests and Responses + Tutorial 2: Requests and Responses - Django REST framework @@ -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)

    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.

    Here is the view for an individual snippet, in the views.py module.

    @@ -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() diff --git a/tutorial/3-class-based-views.html b/tutorial/3-class-based-views.html index 6a5ca7217..c807ad0fa 100644 --- a/tutorial/3-class-based-views.html +++ b/tutorial/3-class-based-views.html @@ -2,7 +2,7 @@ - Django REST framework - Tutorial 3: Class Based Views + Tutorial 3: Class Based Views - Django REST framework diff --git a/tutorial/4-authentication-and-permissions.html b/tutorial/4-authentication-and-permissions.html index 6e166c089..dc1e2212b 100644 --- a/tutorial/4-authentication-and-permissions.html +++ b/tutorial/4-authentication-and-permissions.html @@ -2,7 +2,7 @@ - Django REST framework - Tutorial 4: Authentication & Permissions + Tutorial 4: Authentication & Permissions - Django REST framework @@ -337,10 +337,10 @@ class IsOwnerOrReadOnly(permissions.BasePermission): def has_object_permission(self, request, view, obj): # Read permissions are allowed to any request, # so we'll always allow GET, HEAD or OPTIONS requests. - if request.method in permissions.SAFE_METHODS: + if request.method in permissions.SAFE_METHODS: return True - # Write permissions are only allowed to the owner of the snippet + # Write permissions are only allowed to the owner of the snippet. return obj.owner == request.user

    Now we can add that custom permission to our snippet instance endpoint, by editing the permission_classes property on the SnippetDetail class:

    diff --git a/tutorial/5-relationships-and-hyperlinked-apis.html b/tutorial/5-relationships-and-hyperlinked-apis.html index 9222bc2d3..9b0b5c82a 100644 --- a/tutorial/5-relationships-and-hyperlinked-apis.html +++ b/tutorial/5-relationships-and-hyperlinked-apis.html @@ -2,7 +2,7 @@ - Django REST framework - Tutorial 5: Relationships & Hyperlinked APIs + Tutorial 5: Relationships & Hyperlinked APIs - Django REST framework diff --git a/tutorial/6-viewsets-and-routers.html b/tutorial/6-viewsets-and-routers.html index a5287a793..d178e26d6 100644 --- a/tutorial/6-viewsets-and-routers.html +++ b/tutorial/6-viewsets-and-routers.html @@ -2,7 +2,7 @@ - Django REST framework - Tutorial 6: ViewSets & Routers + Tutorial 6: ViewSets & Routers - Django REST framework diff --git a/tutorial/quickstart.html b/tutorial/quickstart.html index 842cacb1a..fda9ffdc9 100644 --- a/tutorial/quickstart.html +++ b/tutorial/quickstart.html @@ -2,7 +2,7 @@ - Django REST framework - Quickstart + Quickstart - Django REST framework