diff --git a/api-guide/authentication.html b/api-guide/authentication.html index 1dcb47d74..ef0f8ab14 100644 --- a/api-guide/authentication.html +++ b/api-guide/authentication.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
+
@@ -146,9 +149,9 @@ return Response(content)

Or, if you're using the @api_view decorator with function based views.

-
@api_view('GET'),
-@authentication_classes(SessionAuthentication, UserBasicAuthentication)
-@permissions_classes(IsAuthenticated)
+
@api_view(('GET',)),
+@authentication_classes((SessionAuthentication, UserBasicAuthentication))
+@permissions_classes((IsAuthenticated,))
 def example_view(request, format=None):
     content = {
         'user': unicode(request.user),  # `django.contrib.auth.User` instance.
@@ -200,9 +203,19 @@ print token.key
 

To implement a custom authentication policy, subclass BaseAuthentication and override the .authenticate(self, request) method. The method should return a two-tuple of (user, auth) if authentication succeeds, or None otherwise.

-
+
+ + + + diff --git a/api-guide/content-negotiation.html b/api-guide/content-negotiation.html index 09e291fad..7953a3e3c 100644 --- a/api-guide/content-negotiation.html +++ b/api-guide/content-negotiation.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
+
@@ -110,9 +113,19 @@
-
+
+ + + + diff --git a/api-guide/exceptions.html b/api-guide/exceptions.html index d76065e6f..4337672ae 100644 --- a/api-guide/exceptions.html +++ b/api-guide/exceptions.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
+
@@ -162,9 +165,19 @@ Content-Length: 42

By default this exception results in a response with the HTTP status code "429 Too Many Requests".

-
+
+ + + + diff --git a/api-guide/fields.html b/api-guide/fields.html index db528449e..d21b52d97 100644 --- a/api-guide/fields.html +++ b/api-guide/fields.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
+
@@ -143,9 +146,19 @@

ManyHyperlinkedRelatedField

-
+
+ + + + diff --git a/api-guide/format-suffixes.html b/api-guide/format-suffixes.html index 58bb6f0f4..0f14e8216 100644 --- a/api-guide/format-suffixes.html +++ b/api-guide/format-suffixes.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
+
@@ -111,9 +114,19 @@ used all the time.

-
+
+ + + + diff --git a/api-guide/generic-views.html b/api-guide/generic-views.html index d6ef752b2..8a42ce7fd 100644 --- a/api-guide/generic-views.html +++ b/api-guide/generic-views.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
+
@@ -198,9 +201,19 @@

Provides a .destroy(request, *args, **kwargs) method, that implements deletion of an existing model instance.

-
+
+ + + + diff --git a/api-guide/pagination.html b/api-guide/pagination.html index 0caf4a58d..978b37093 100644 --- a/api-guide/pagination.html +++ b/api-guide/pagination.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
+
@@ -207,9 +210,19 @@ class CustomPaginationSerializer(pagination.BasePaginationSerializer):
-
+
+ + + + diff --git a/api-guide/parsers.html b/api-guide/parsers.html index ddbbd715f..d85a99260 100644 --- a/api-guide/parsers.html +++ b/api-guide/parsers.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
+
@@ -124,9 +127,19 @@ sending more complex data than simple forms

Custom parsers

-
+
+ + + + diff --git a/api-guide/permissions.html b/api-guide/permissions.html index e3d326421..cb8b804a2 100644 --- a/api-guide/permissions.html +++ b/api-guide/permissions.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
+
@@ -177,9 +180,19 @@ def example_view(request, format=None):

The method should return True if the request should be granted access, and False otherwise.

-
+
+ + + + diff --git a/api-guide/renderers.html b/api-guide/renderers.html index 729e14e08..268185783 100644 --- a/api-guide/renderers.html +++ b/api-guide/renderers.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
+
@@ -108,6 +111,7 @@
  • HTMLTemplateRenderer
  • Custom renderers
  • Advanced renderer usage
  • +
  • Varying behaviour by media type
  • Designing your media types
  • @@ -162,6 +166,7 @@ def user_count_view(request, format=None):

    It's important when specifying the renderer classes for your API to think about what priority you want to assign to each media type. If a client underspecifies the representations it can accept, such as sending an Accept: */* header, or not including an Accept header at all, then REST framework will select the first renderer in the list to use for the response.

    For example if your API serves JSON responses and the HTML browseable API, you might want to make JSONRenderer your default renderer, in order to send JSON responses to clients that do not specify an Accept header.

    If your API includes views that can serve both regular webpages and API responses depending on the request, then you might consider making TemplateHTMLRenderer your default renderer, in order to play nicely with older browsers that send broken accept headers.

    +

    API Reference

    JSONRenderer

    .media_type: application/json

    @@ -195,6 +200,7 @@ Unlike other renderers, the data passed to the Response does not ne

    .format: '.html'

    Custom renderers

    To implement a custom renderer, you should override BaseRenderer, set the .media_type and .format properties, and implement the .render(self, data, media_type) method.

    +

    Advanced renderer usage

    You can do some pretty flexible things using REST framework's renderers. Some examples...

      @@ -203,6 +209,7 @@ Unlike other renderers, the data passed to the Response does not ne
    • Specify multiple types of HTML representation for API clients to use.
    • Underspecify a renderer's media type, such as using media_type = 'image/*', and use the Accept header to vary the encoding of the response.
    +

    Varying behaviour by media type

    In some cases you might want your view to use different serialization styles depending on the accepted media type. If you need to do this you can access request.accepted_renderer to determine the negotiated renderer that will be used for the response.

    For example:

    @api_view(('GET',))
    @@ -232,9 +239,19 @@ def list_users(request):
     

    For good examples of custom media types, see GitHub's use of a custom application/vnd.github+json media type, and Mike Amundsen's IANA approved application/vnd.collection+json JSON-based hypermedia.

    -
    +
    + + + + diff --git a/api-guide/requests.html b/api-guide/requests.html index 86c4e5a0a..ecad4e00f 100644 --- a/api-guide/requests.html +++ b/api-guide/requests.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -149,9 +152,19 @@

    If you're using the rest_framework.views.View class... [TODO]

    -
    +
    + + + + diff --git a/api-guide/responses.html b/api-guide/responses.html index d16b7270f..39a7c557a 100644 --- a/api-guide/responses.html +++ b/api-guide/responses.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -149,11 +152,11 @@ response['Cache-Control'] = 'no-cache'

    Attributes

    .data

    -

    The unrendered content of a Request object can be accessed using the .data attribute.

    +

    The unrendered content of a Request object.

    .status_code

    The numeric status code of the HTTP response.

    .content

    -

    The rendered content of the response. .render() must have been called before .content can be accessed.

    +

    The rendered content of the response. The .render() method must have been called before .content can be accessed.

    .template_name

    The template_name, if supplied. Only required if HTMLTemplateRenderer or some other custom template renderer is the accepted renderer for the reponse.

    .accepted_renderer

    @@ -164,9 +167,19 @@ response['Cache-Control'] = 'no-cache'

    Set automatically by the APIView or @api_view immediately before the response is returned from the view.

    -
    +
    + + + + diff --git a/api-guide/reverse.html b/api-guide/reverse.html index 947aa09b5..ea3cd38ce 100644 --- a/api-guide/reverse.html +++ b/api-guide/reverse.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -141,9 +144,19 @@ class APIRootView(APIView):

    Has the same behavior as django.core.urlresolvers.reverse_lazy, except that it returns a fully qualified URL, using the request to determine the host and port.

    -
    +
    + + + + diff --git a/api-guide/serializers.html b/api-guide/serializers.html index 3edc66d0e..906a56a6a 100644 --- a/api-guide/serializers.html +++ b/api-guide/serializers.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -306,9 +309,19 @@ The ModelSerializer class lets you automatically create a Serialize
    -
    +
    + + + + diff --git a/api-guide/settings.html b/api-guide/settings.html index d6c6d2471..63e6fc771 100644 --- a/api-guide/settings.html +++ b/api-guide/settings.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -209,9 +212,19 @@ print api_settings.DEFAULT_AUTHENTICATION

    Default: 'format'

    -
    +
    + + + + diff --git a/api-guide/status-codes.html b/api-guide/status-codes.html index 1b5984374..29d7a667f 100644 --- a/api-guide/status-codes.html +++ b/api-guide/status-codes.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -185,9 +188,19 @@ HTTP_511_NETWORD_AUTHENTICATION_REQUIRED
    -
    +
    + + + + diff --git a/api-guide/throttling.html b/api-guide/throttling.html index 27bb4b469..3814cc50b 100644 --- a/api-guide/throttling.html +++ b/api-guide/throttling.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -225,9 +228,19 @@ class UploadView(APIView):

    Optionally you may also override the .wait() method. If implemented, .wait() should return a recomended number of seconds to wait before attempting the next request, or None. The .wait() method will only be called if .check_throttle() has previously returned False.

    -
    +
    + + + + diff --git a/api-guide/views.html b/api-guide/views.html index d645ef032..41e40d894 100644 --- a/api-guide/views.html +++ b/api-guide/views.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -165,7 +168,7 @@

    The following methods are called directly by the view's .dispatch() method. These perform any actions that need to occur before or after calling the handler methods such as .get(), .post(), put() and .delete().

    -

    .initial(self, request, args, *kwargs)

    +

    .initial(self, request, *args, **kwargs)

    Performs any actions that need to occur before the handler method gets called. This method is used to enforce permissions and throttling, and perform content negotiation.

    You won't typically need to override this method.

    @@ -173,10 +176,10 @@ This method is used to enforce permissions and throttling, and perform content n

    Any exception thrown by the handler method will be passed to this method, which either returns a Response instance, or re-raises the exception.

    The default implementation handles any subclass of rest_framework.exceptions.APIException, as well as Django's Http404 and PermissionDenied exceptions, and returns an appropriate error response.

    If you need to customize the error responses your API returns you should subclass this method.

    -

    .initialize_request(self, request, args, *kwargs)

    +

    .initialize_request(self, request, *args, **kwargs)

    Ensures that the request object that is passed to the handler method is an instance of Request, rather than the usual Django HttpRequest.

    You won't typically need to override this method.

    -

    .finalize_response(self, request, response, args, *kwargs)

    +

    .finalize_response(self, request, response, *args, **kwargs)

    Ensures that any Response object returned from the handler method will be rendered into the correct content type, as determined by the content negotation.

    You won't typically need to override this method.


    @@ -189,9 +192,19 @@ This method is used to enforce permissions and throttling, and perform content n

    [TODO]

    -
    +
    + + + + diff --git a/css/default.css b/css/default.css index 5a73fb99d..8401687d5 100644 --- a/css/default.css +++ b/css/default.css @@ -61,6 +61,30 @@ a.github:hover { text-decoration: none; } +/* Footer */ +/* +.footer p { + text-align: center; + color: gray; + border-top: 1px solid #DDD; + padding-top: 10px; +} + +.footer a { + color: gray; + font-weight: bold; +} + +.footer a:hover { + color: gray; +} +*/ + +/* */ +body hr { + border-top: 1px dotted #A30000 +} + /* Force TOC text to not overrun */ #table-of-contents { overflow: hidden; diff --git a/img/favicon.ico b/img/favicon.ico new file mode 100644 index 000000000..917892ad5 Binary files /dev/null and b/img/favicon.ico differ diff --git a/index.html b/index.html index 7ff1b0e19..ebeed863d 100644 --- a/index.html +++ b/index.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -226,9 +229,19 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    -
    +
    + + + + diff --git a/topics/browsable-api.html b/topics/browsable-api.html index 3b5dc4b7d..09a328ade 100644 --- a/topics/browsable-api.html +++ b/topics/browsable-api.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -167,9 +170,19 @@

    For more advanced customization, such as not having a Bootstrap basis or tighter integration with the rest of your site, you can simply choose not to have api.html extend base.html. Then the page content and capabilities are entirely up to you.

    -
    +
    + + + + diff --git a/topics/changelog.html b/topics/changelog.html index 3ddd2bf0e..aebea797d 100644 --- a/topics/changelog.html +++ b/topics/changelog.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -229,9 +232,19 @@
    -
    +
    + + + + diff --git a/topics/contributing.html b/topics/contributing.html index fe02acea7..3e447e484 100644 --- a/topics/contributing.html +++ b/topics/contributing.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -116,9 +119,19 @@

    Describe compat module

    -
    +
    + + + + diff --git a/topics/credits.html b/topics/credits.html index 233e41dfa..6349bc799 100644 --- a/topics/credits.html +++ b/topics/credits.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -165,9 +168,19 @@
    -
    +
    + + + + diff --git a/topics/csrf.html b/topics/csrf.html index 19cf357a5..7e18b4abe 100644 --- a/topics/csrf.html +++ b/topics/csrf.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -114,9 +117,19 @@
    -
    +
    + + + + diff --git a/topics/formoverloading.html b/topics/formoverloading.html index f225bacba..5882ffcb9 100644 --- a/topics/formoverloading.html +++ b/topics/formoverloading.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -135,9 +138,19 @@

    Nope. It was at one point intended to support PUT and DELETE forms, but was later dropped from the spec. There remains ongoing discussion about adding support for PUT and DELETE, as well as how to support content types other than form-encoded data.

    -
    +
    + + + + diff --git a/topics/rest-hypermedia-hateoas.html b/topics/rest-hypermedia-hateoas.html index f26ee44f8..127e6f8d2 100644 --- a/topics/rest-hypermedia-hateoas.html +++ b/topics/rest-hypermedia-hateoas.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -130,9 +133,19 @@ the Design of Network-based Software Architectures.

    What REST framework doesn't do is give you is machine readable hypermedia formats such as Collection+JSON by default, or the ability to auto-magically create HATEOAS style APIs. Doing so would involve making opinionated choices about API design that should really remain outside of the framework's scope.

    -
    +
    + + + + diff --git a/tutorial/1-serialization.html b/tutorial/1-serialization.html index 8079f8b30..43f05aa3c 100644 --- a/tutorial/1-serialization.html +++ b/tutorial/1-serialization.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -129,7 +132,8 @@ pip install djangorestframework

    Getting started

    Okay, we're ready to get coding. To get started, let's create a new project to work with.

    -
    django-admin.py startproject tutorial
    +
    cd ~
    +django-admin.py startproject tutorial
     cd tutorial
     

    Once that's done we can create an app that we'll use to create a simple Web API.

    @@ -173,7 +177,7 @@ class Comment(models.Model):
    python manage.py syncdb
     

    Creating a Serializer class

    -

    We're going to create a simple Web API that we can use to edit these comment objects with. The first thing we need is a way of serializing and deserializing the objects into representations such as json. We do this by declaring serializers that work very similarly to Django's forms. Create a file in the project named serializers.py and add the following.

    +

    We're going to create a simple Web API that we can use to edit these comment objects with. The first thing we need is a way of serializing and deserializing the objects into representations such as json. We do this by declaring serializers that work very similarly to Django's forms. Create a file in the blog directory named serializers.py and add the following.

    from blog import models
     from rest_framework import serializers
     
    @@ -325,9 +329,19 @@ urlpatterns = patterns('blog.views',
     

    We'll see how we can start to improve things in part 2 of the tutorial.

    -
    +
    + + + + diff --git a/tutorial/2-requests-and-responses.html b/tutorial/2-requests-and-responses.html index 87b75aa98..2666f01dd 100644 --- a/tutorial/2-requests-and-responses.html +++ b/tutorial/2-requests-and-responses.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -222,9 +225,19 @@ urlpatterns = format_suffix_patterns(urlpatterns)

    In tutorial part 3, we'll start using class based views, and see how generic views reduce the amount of code we need to write.

    -
    +
    + + + + diff --git a/tutorial/3-class-based-views.html b/tutorial/3-class-based-views.html index cb1e8bffa..f85d1d2ce 100644 --- a/tutorial/3-class-based-views.html +++ b/tutorial/3-class-based-views.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -236,9 +239,19 @@ class CommentInstance(generics.RetrieveUpdateDestroyAPIView):

    Next we'll move onto part 4 of the tutorial, where we'll take a look at how we can customize the behavior of our views to support a range of authentication, permissions, throttling and other aspects.

    -
    +
    + + + + diff --git a/tutorial/4-authentication-permissions-and-throttling.html b/tutorial/4-authentication-permissions-and-throttling.html index 888c5edfe..72484dce4 100644 --- a/tutorial/4-authentication-permissions-and-throttling.html +++ b/tutorial/4-authentication-permissions-and-throttling.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -106,9 +109,19 @@

    Nothing to see here. Onwards to part 5.

    -
    +
    + + + + diff --git a/tutorial/5-relationships-and-hyperlinked-apis.html b/tutorial/5-relationships-and-hyperlinked-apis.html index 4524088b8..57e9e4924 100644 --- a/tutorial/5-relationships-and-hyperlinked-apis.html +++ b/tutorial/5-relationships-and-hyperlinked-apis.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -112,9 +115,19 @@

    Onwards to part 6.

    -
    +
    + + + + diff --git a/tutorial/6-resource-orientated-projects.html b/tutorial/6-resource-orientated-projects.html index be3a92849..3d7f49fbf 100644 --- a/tutorial/6-resource-orientated-projects.html +++ b/tutorial/6-resource-orientated-projects.html @@ -2,6 +2,7 @@ Django REST framework + @@ -89,6 +90,8 @@ +
    +
    @@ -171,9 +174,19 @@ urlpatterns = router.urlpatterns

    Now go build some awesome things.

    -
    +
    + + + +