mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-12-04 07:24:03 +03:00
Docs tweaks
This commit is contained in:
parent
5393cacca8
commit
6c40fc362f
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="authentication-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#authentication">Authentication</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#authentication">Authentication</a></li>
|
||||
<li><a href="#how-authentication-is-determined">How authentication is determined</a></li>
|
||||
<li><a href="#setting-the-authentication-policy">Setting the authentication policy</a></li>
|
||||
<li><a href="#basicauthentication">BasicAuthentication</a></li>
|
||||
|
@ -108,12 +109,12 @@
|
|||
<li><a href="#sessionauthentication">SessionAuthentication</a></li>
|
||||
<li><a href="#custom-authentication-policies">Custom authentication policies</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/authentication.py"><span class="label label-info">authentication.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/authentication.py"><span class="label label-info">authentication.py</span></a></p>
|
||||
<h1 id="authentication">Authentication</h1>
|
||||
<blockquote>
|
||||
<p>Auth needs to be pluggable.</p>
|
||||
|
@ -202,20 +203,17 @@ print token.key
|
|||
</ul>
|
||||
<h2 id="custom-authentication-policies">Custom authentication policies</h2>
|
||||
<p>To implement a custom authentication policy, subclass <code>BaseAuthentication</code> and override the <code>.authenticate(self, request)</code> method. The method should return a two-tuple of <code>(user, auth)</code> if authentication succeeds, or <code>None</code> otherwise.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="content-negotiation-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,41 +93,37 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#content-negotiation">Content negotiation</a></li>
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#content-negotiation">Content negotiation</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/negotiation.py"><span class="label label-info">negotiation.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/negotiation.py"><span class="label label-info">negotiation.py</span></a></p>
|
||||
<h1 id="content-negotiation">Content negotiation</h1>
|
||||
<blockquote>
|
||||
<p>HTTP has provisions for several mechanisms for "content negotiation" - the process of selecting the best representation for a given response when there are multiple representations available.</p>
|
||||
<p>— <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html">RFC 2616</a>, Fielding et al.</p>
|
||||
</blockquote>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="exceptions-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#exceptions">Exceptions</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#exceptions">Exceptions</a></li>
|
||||
<li><a href="#exception-handling-in-rest-framework-views">Exception handling in REST framework views</a></li>
|
||||
<li><a href="#apiexception">APIException</a></li>
|
||||
<li><a href="#parseerror">ParseError</a></li>
|
||||
|
@ -108,12 +109,12 @@
|
|||
<li><a href="#unsupportedmediatype">UnsupportedMediaType</a></li>
|
||||
<li><a href="#throttled">Throttled</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/exceptions.py"><span class="label label-info">exceptions.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/exceptions.py"><span class="label label-info">exceptions.py</span></a></p>
|
||||
<h1 id="exceptions">Exceptions</h1>
|
||||
<blockquote>
|
||||
<p>Exceptions… allow error handling to be organized cleanly in a central or high-level place within the program structure.</p>
|
||||
|
@ -164,20 +165,17 @@ Content-Length: 42
|
|||
<p><strong>Signature:</strong> <code>Throttled(wait=None, detail=None)</code></p>
|
||||
<p>Raised when an incoming request fails the throttling checks.</p>
|
||||
<p>By default this exception results in a response with the HTTP status code "429 Too Many Requests".</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="fields-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#serializer-fields">Serializer fields</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#serializer-fields">Serializer fields</a></li>
|
||||
<li class="main"><a href="#generic-fields">Generic Fields</a></li>
|
||||
<li><a href="#field">Field</a></li>
|
||||
<li><a href="#writablefield">WritableField</a></li>
|
||||
|
@ -119,19 +120,21 @@
|
|||
<li><a href="#manyhyperlinkedrelatedfield">ManyHyperlinkedRelatedField</a></li>
|
||||
<li><a href="#hyperlinkedidentityfield">HyperLinkedIdentityField</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/fields.py"><span class="label label-info">fields.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/fields.py"><span class="label label-info">fields.py</span></a></p>
|
||||
<h1 id="serializer-fields">Serializer fields</h1>
|
||||
<blockquote>
|
||||
<p>Flat is better than nested.</p>
|
||||
<p>— <a href="http://www.python.org/dev/peps/pep-0020/">The Zen of Python</a></p>
|
||||
</blockquote>
|
||||
<p><strong>Note:</strong> The serializer fields are declared in fields.py, but by convention you should import them using <code>from rest_framework import serializers</code> and refer to fields as <code>serializers.<FieldName></code>.</p>
|
||||
<p>Serializer fields handle converting between primative values and internal datatypes. They also deal with validating input values, as well as retrieving and setting the values from their parent objects.</p>
|
||||
<hr />
|
||||
<p><strong>Note:</strong> The serializer fields are declared in fields.py, but by convention you should import them using <code>from rest_framework import serializers</code> and refer to fields as <code>serializers.<FieldName></code>.</p>
|
||||
<hr />
|
||||
<h1 id="generic-fields">Generic Fields</h1>
|
||||
<h2 id="field">Field</h2>
|
||||
<p>A generic, read-only field. You can use this field for any attribute that does not need to support write operations.</p>
|
||||
|
@ -156,20 +159,17 @@
|
|||
<h2 id="hyperlinkedrelatedfield">HyperlinkedRelatedField</h2>
|
||||
<h2 id="manyhyperlinkedrelatedfield">ManyHyperlinkedRelatedField</h2>
|
||||
<h2 id="hyperlinkedidentityfield">HyperLinkedIdentityField</h2>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="format-suffixes-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,42 +93,38 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#format-suffixes">Format suffixes</a></li>
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#format-suffixes">Format suffixes</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/urlpatterns.py"><span class="label label-info">urlpatterns.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/urlpatterns.py"><span class="label label-info">urlpatterns.py</span></a></p>
|
||||
<h1 id="format-suffixes">Format suffixes</h1>
|
||||
<blockquote>
|
||||
<p>Section 6.2.1 does not say that content negotiation should be
|
||||
used all the time.</p>
|
||||
<p>— Roy Fielding, <a href="http://tech.groups.yahoo.com/group/rest-discuss/message/5857">REST discuss mailing list</a></p>
|
||||
</blockquote>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="generic-views-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#generic-views">Generic views</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#generic-views">Generic views</a></li>
|
||||
<li><a href="#examples">Examples</a></li>
|
||||
<li class="main"><a href="#api-reference">API Reference</a></li>
|
||||
<li><a href="#listapiview">ListAPIView</a></li>
|
||||
|
@ -117,12 +118,12 @@
|
|||
<li><a href="#updatemodelmixin">UpdateModelMixin</a></li>
|
||||
<li><a href="#destroymodelmixin">DestroyModelMixin</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/mixins.py"><span class="label label-info">mixins.py</span></a>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/mixins.py"><span class="label label-info">mixins.py</span></a>
|
||||
<a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/generics.py"><span class="label label-info">generics.py</span></a></p>
|
||||
<h1 id="generic-views">Generic views</h1>
|
||||
<blockquote>
|
||||
|
@ -200,20 +201,17 @@
|
|||
<p>Provides a <code>.update(request, *args, **kwargs)</code> method, that implements updating and saving an existing model instance.</p>
|
||||
<h2 id="destroymodelmixin">DestroyModelMixin</h2>
|
||||
<p>Provides a <code>.destroy(request, *args, **kwargs)</code> method, that implements deletion of an existing model instance.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="pagination-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,26 +93,25 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#pagination">Pagination</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#pagination">Pagination</a></li>
|
||||
<li><a href="#paginating-basic-data">Paginating basic data</a></li>
|
||||
<li><a href="#paginating-querysets">Paginating QuerySets</a></li>
|
||||
<li><a href="#pagination-in-the-generic-views">Pagination in the generic views</a></li>
|
||||
<li><a href="#creating-custom-pagination-serializers">Creating custom pagination serializers</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/pagination.py"><span class="label label-info">pagination.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/pagination.py"><span class="label label-info">pagination.py</span></a></p>
|
||||
<h1 id="pagination">Pagination</h1>
|
||||
<blockquote>
|
||||
<p>Django provides a few classes that help you manage paginated data – that is, data that’s split across several pages, with “Previous/Next” links.</p>
|
||||
|
@ -209,20 +210,17 @@ class CustomPaginationSerializer(pagination.BasePaginationSerializer):
|
|||
|
||||
results_field = 'objects'
|
||||
</code></pre>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="parsers-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#parsers">Parsers</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#parsers">Parsers</a></li>
|
||||
<li><a href="#jsonparser">JSONParser</a></li>
|
||||
<li><a href="#yamlparser">YAMLParser</a></li>
|
||||
<li><a href="#xmlparser">XMLParser</a></li>
|
||||
|
@ -107,12 +108,12 @@
|
|||
<li><a href="#multipartparser">MultiPartParser</a></li>
|
||||
<li><a href="#custom-parsers">Custom parsers</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/parsers.py"><span class="label label-info">parsers.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/parsers.py"><span class="label label-info">parsers.py</span></a></p>
|
||||
<h1 id="parsers">Parsers</h1>
|
||||
<blockquote>
|
||||
<p>Machine interacting web services tend to use more
|
||||
|
@ -126,20 +127,17 @@ sending more complex data than simple forms</p>
|
|||
<h2 id="formparser">FormParser</h2>
|
||||
<h2 id="multipartparser">MultiPartParser</h2>
|
||||
<h2 id="custom-parsers">Custom parsers</h2>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="permissions-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#permissions">Permissions</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#permissions">Permissions</a></li>
|
||||
<li><a href="#how-permissions-are-determined">How permissions are determined</a></li>
|
||||
<li><a href="#object-level-permissions">Object level permissions</a></li>
|
||||
<li><a href="#setting-the-permission-policy">Setting the permission policy</a></li>
|
||||
|
@ -109,12 +110,12 @@
|
|||
<li><a href="#djangomodelpermissions">DjangoModelPermissions</a></li>
|
||||
<li><a href="#custom-permissions">Custom permissions</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/permissions.py"><span class="label label-info">permissions.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/permissions.py"><span class="label label-info">permissions.py</span></a></p>
|
||||
<h1 id="permissions">Permissions</h1>
|
||||
<blockquote>
|
||||
<p>Authentication or identification by itself is not usually sufficient to gain access to information or code. For that, the entity requesting access must have authorization.</p>
|
||||
|
@ -179,20 +180,17 @@ def example_view(request, format=None):
|
|||
<h2 id="custom-permissions">Custom permissions</h2>
|
||||
<p>To implement a custom permission, override <code>BasePermission</code> and implement the <code>.has_permission(self, request, obj=None)</code> method.</p>
|
||||
<p>The method should return <code>True</code> if the request should be granted access, and <code>False</code> otherwise.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="renderers-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#renderers">Renderers</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#renderers">Renderers</a></li>
|
||||
<li><a href="#how-the-renderer-is-determined">How the renderer is determined</a></li>
|
||||
<li><a href="#setting-the-renderers">Setting the renderers</a></li>
|
||||
<li><a href="#ordering-of-renderer-classes">Ordering of renderer classes</a></li>
|
||||
|
@ -115,12 +116,12 @@
|
|||
<li><a href="#varying-behaviour-by-media-type">Varying behaviour by media type</a></li>
|
||||
<li><a href="#designing-your-media-types">Designing your media types</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/renderers.py"><span class="label label-info">renderers.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/renderers.py"><span class="label label-info">renderers.py</span></a></p>
|
||||
<h1 id="renderers">Renderers</h1>
|
||||
<blockquote>
|
||||
<p>Before a TemplateResponse instance can be returned to the client, it must be rendered. The rendering process takes the intermediate representation of template and context, and turns it into the final byte stream that can be served to the client.</p>
|
||||
|
@ -238,20 +239,17 @@ def list_users(request):
|
|||
<p>For the purposes of many Web APIs, simple <code>JSON</code> responses with hyperlinked relations may be sufficient. If you want to fully embrace RESTful design and <a href="http://timelessrepo.com/haters-gonna-hateoas">HATEOAS</a> you'll neeed to consider the design and usage of your media types in more detail.</p>
|
||||
<p>In <a href="http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven">the words of Roy Fielding</a>, "A REST API should spend almost all of its descriptive effort in defining the media type(s) used for representing resources and driving application state, or in defining extended relation names and/or hypertext-enabled mark-up for existing standard media types.".</p>
|
||||
<p>For good examples of custom media types, see GitHub's use of a custom <a href="http://developer.github.com/v3/media/">application/vnd.github+json</a> media type, and Mike Amundsen's IANA approved <a href="http://www.amundsen.com/media-types/collection/">application/vnd.collection+json</a> JSON-based hypermedia.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="requests-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#requests">Requests</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#requests">Requests</a></li>
|
||||
<li><a href="#method">.method</a></li>
|
||||
<li><a href="#content_type">.content_type</a></li>
|
||||
<li><a href="#data">.DATA</a></li>
|
||||
|
@ -110,12 +111,12 @@
|
|||
<li><a href="#stream">.stream</a></li>
|
||||
<li><a href="#authentication">.authentication</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/request.py"><span class="label label-info">request.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/request.py"><span class="label label-info">request.py</span></a></p>
|
||||
<h1 id="requests">Requests</h1>
|
||||
<blockquote>
|
||||
<p>If you're doing REST-based web service stuff ... you should ignore request.POST.</p>
|
||||
|
@ -151,20 +152,17 @@
|
|||
<p><code>request.authentication</code> should be set to a list of <code>Authentication</code> instances that can be used to authenticate the request.</p>
|
||||
<p><code>request.authentication</code> may no longer be altered once <code>request.user</code> or <code>request.auth</code> have been accessed.</p>
|
||||
<p>If you're using the <code>rest_framework.views.View</code> class... <strong>[TODO]</strong></p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="responses-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#responses">Responses</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#responses">Responses</a></li>
|
||||
<li class="main"><a href="#methods">Methods</a></li>
|
||||
<li><a href="#response()">Response()</a></li>
|
||||
<li><a href="#render()">.render()</a></li>
|
||||
|
@ -112,12 +113,12 @@
|
|||
<li><a href="#accepted_renderer">.accepted_renderer</a></li>
|
||||
<li><a href="#accepted_media_type">.accepted_media_type</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/response.py"><span class="label label-info">response.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/response.py"><span class="label label-info">response.py</span></a></p>
|
||||
<h1 id="responses">Responses</h1>
|
||||
<blockquote>
|
||||
<p>Unlike basic HttpResponse objects, TemplateResponse objects retain the details of the context that was provided by the view to compute the response. The final output of the response is not computed until it is needed, later in the response process.</p>
|
||||
|
@ -166,20 +167,17 @@ response['Cache-Control'] = 'no-cache'
|
|||
<h2 id="accepted_media_type">.accepted_media_type</h2>
|
||||
<p>The media type that was selected by the content negotiation stage.</p>
|
||||
<p>Set automatically by the <code>APIView</code> or <code>@api_view</code> immediately before the response is returned from the view.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="reverse-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,24 +93,23 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#returning-urls">Returning URLs</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#returning-urls">Returning URLs</a></li>
|
||||
<li><a href="#reverse">reverse</a></li>
|
||||
<li><a href="#reverse_lazy">reverse_lazy</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/reverse.py"><span class="label label-info">reverse.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/reverse.py"><span class="label label-info">reverse.py</span></a></p>
|
||||
<h1 id="returning-urls">Returning URLs</h1>
|
||||
<blockquote>
|
||||
<p>The central feature that distinguishes the REST architectural style from other network-based styles is its emphasis on a uniform interface between components.</p>
|
||||
|
@ -143,20 +144,17 @@ class APIRootView(APIView):
|
|||
<h2 id="reverse_lazy">reverse_lazy</h2>
|
||||
<p><strong>Signature:</strong> <code>reverse_lazy(viewname, request, *args, **kwargs)</code></p>
|
||||
<p>Has the same behavior as <a href="https://docs.djangoproject.com/en/dev/topics/http/urls/#reverse-lazy"><code>django.core.urlresolvers.reverse_lazy</code></a>, except that it returns a fully qualified URL, using the request to determine the host and port.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="serializers-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#serializers">Serializers</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#serializers">Serializers</a></li>
|
||||
<li><a href="#declaring-serializers">Declaring Serializers</a></li>
|
||||
<li><a href="#serializing-objects">Serializing objects</a></li>
|
||||
<li><a href="#deserializing-objects">Deserializing objects</a></li>
|
||||
|
@ -113,12 +114,12 @@
|
|||
<li><a href="#specifiying-nested-serialization">Specifiying nested serialization</a></li>
|
||||
<li><a href="#customising-the-default-fields-used-by-a-modelserializer">Customising the default fields used by a ModelSerializer</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/serializers.py"><span class="label label-info">serializers.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/serializers.py"><span class="label label-info">serializers.py</span></a></p>
|
||||
<h1 id="serializers">Serializers</h1>
|
||||
<blockquote>
|
||||
<p>Expanding the usefulness of the serializers is something that we would
|
||||
|
@ -308,20 +309,17 @@ The <code>ModelSerializer</code> class lets you automatically create a Serialize
|
|||
def get_field(self, model_field):
|
||||
return Field()
|
||||
</code></pre>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="settings-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#settings">Settings</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#settings">Settings</a></li>
|
||||
<li><a href="#accessing-settings">Accessing settings</a></li>
|
||||
<li><a href="#default_renderers">DEFAULT_RENDERERS</a></li>
|
||||
<li><a href="#default_parsers">DEFAULT_PARSERS</a></li>
|
||||
|
@ -117,12 +118,12 @@
|
|||
<li><a href="#url_accept_override">URL_ACCEPT_OVERRIDE</a></li>
|
||||
<li><a href="#url_format_override">URL_FORMAT_OVERRIDE</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/settings.py"><span class="label label-info">settings.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/settings.py"><span class="label label-info">settings.py</span></a></p>
|
||||
<h1 id="settings">Settings</h1>
|
||||
<blockquote>
|
||||
<p>Namespaces are one honking great idea - let's do more of those!</p>
|
||||
|
@ -211,20 +212,17 @@ print api_settings.DEFAULT_AUTHENTICATION
|
|||
<p>Default: <code>'accept'</code></p>
|
||||
<h2 id="url_format_override">URL_FORMAT_OVERRIDE</h2>
|
||||
<p>Default: <code>'format'</code></p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="status-codes-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,27 +93,26 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#status-codes">Status Codes</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#status-codes">Status Codes</a></li>
|
||||
<li><a href="#informational---1xx">Informational - 1xx</a></li>
|
||||
<li><a href="#successful---2xx">Successful - 2xx</a></li>
|
||||
<li><a href="#redirection---3xx">Redirection - 3xx</a></li>
|
||||
<li><a href="#client-error---4xx">Client Error - 4xx</a></li>
|
||||
<li><a href="#server-error---5xx">Server Error - 5xx</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/status.py"><span class="label label-info">status.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/status.py"><span class="label label-info">status.py</span></a></p>
|
||||
<h1 id="status-codes">Status Codes</h1>
|
||||
<blockquote>
|
||||
<p>418 I'm a teapot - Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot". The resulting entity body MAY be short and stout.</p>
|
||||
|
@ -187,20 +188,17 @@ HTTP_504_GATEWAY_TIMEOUT
|
|||
HTTP_505_HTTP_VERSION_NOT_SUPPORTED
|
||||
HTTP_511_NETWORD_AUTHENTICATION_REQUIRED
|
||||
</code></pre>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="throttling-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#throttling">Throttling</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#throttling">Throttling</a></li>
|
||||
<li><a href="#how-throttling-is-determined">How throttling is determined</a></li>
|
||||
<li><a href="#setting-the-throttling-policy">Setting the throttling policy</a></li>
|
||||
<li><a href="#anonratethrottle">AnonRateThrottle</a></li>
|
||||
|
@ -107,12 +108,12 @@
|
|||
<li><a href="#scopedratethrottle">ScopedRateThrottle</a></li>
|
||||
<li><a href="#custom-throttles">Custom throttles</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/throttling.py"><span class="label label-info">throttling.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/throttling.py"><span class="label label-info">throttling.py</span></a></p>
|
||||
<h1 id="throttling">Throttling</h1>
|
||||
<blockquote>
|
||||
<p>HTTP/1.1 420 Enhance Your Calm</p>
|
||||
|
@ -227,20 +228,17 @@ class UploadView(APIView):
|
|||
<h2 id="custom-throttles">Custom throttles</h2>
|
||||
<p>To create a custom throttle, override <code>BaseThrottle</code> and implement <code>.allow_request(request)</code>. The method should return <code>True</code> if the request should be allowed, and <code>False</code> otherwise.</p>
|
||||
<p>Optionally you may also override the <code>.wait()</code> method. If implemented, <code>.wait()</code> should return a recomended number of seconds to wait before attempting the next request, or <code>None</code>. The <code>.wait()</code> method will only be called if <code>.check_throttle()</code> has previously returned <code>False</code>.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="views-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,27 +93,26 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#class-based-views">Class Based Views</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#class-based-views">Class Based Views</a></li>
|
||||
<li><a href="#api-policy-attributes">API policy attributes</a></li>
|
||||
<li><a href="#api-policy-instantiation-methods">API policy instantiation methods</a></li>
|
||||
<li><a href="#api-policy-implementation-methods">API policy implementation methods</a></li>
|
||||
<li><a href="#dispatch-methods">Dispatch methods</a></li>
|
||||
<li class="main"><a href="#function-based-views">Function Based Views</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/decorators.py"><span class="label label-info">decorators.py</span></a> <a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/views.py"><span class="label label-info">views.py</span></a></p>
|
||||
<div id="main-content" class="span9">
|
||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/decorators.py"><span class="label label-info">decorators.py</span></a> <a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/views.py"><span class="label label-info">views.py</span></a></p>
|
||||
<h1 id="class-based-views">Class Based Views</h1>
|
||||
<blockquote>
|
||||
<p>Django's class based views are a welcome departure from the old-style views.</p>
|
||||
|
@ -191,20 +192,17 @@ This method is used to enforce permissions and throttling, and perform content n
|
|||
</blockquote>
|
||||
<p>REST framework also gives you to work with regular function based views...</p>
|
||||
<p><strong>[TODO]</strong></p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
/* Set the body padding-top when above 980px to push the content down from
|
||||
below the navbar, which is fixed at >980px screen widths. */
|
||||
@media (min-width: 980px) {
|
||||
body {
|
||||
padding-top: 71px;
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
|
||||
pre {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
@ -61,28 +51,9 @@ 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
|
||||
border-top: 1px dotted #A30000;
|
||||
}
|
||||
|
||||
/* Force TOC text to not overrun */
|
||||
|
@ -100,7 +71,7 @@ pre {
|
|||
|
||||
/* Preserve the spacing of the navbar across different screen sizes. */
|
||||
.navbar-inner {
|
||||
padding: 5px 0;
|
||||
/*padding: 5px 0;*/
|
||||
}
|
||||
|
||||
@media (max-width: 979px) {
|
||||
|
@ -194,8 +165,9 @@ body{
|
|||
color: white;
|
||||
}
|
||||
|
||||
.nav-list > .active > a, .nav-list > .active > a:hover {
|
||||
background: #2c2c2c;
|
||||
.nav-list > .active > a, .navbar .navbar-inner .nav li a:hover {
|
||||
background:#212121;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.navbar .navbar-inner .dropdown-menu li a, .navbar .navbar-inner .dropdown-menu li{
|
||||
|
@ -233,3 +205,40 @@ body a:hover{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* sticky footer and footer */
|
||||
html, body {
|
||||
height: 100%;
|
||||
}
|
||||
.wrapper {
|
||||
min-height: 100%;
|
||||
height: auto !important;
|
||||
height: 100%;
|
||||
margin: 0 auto -60px;
|
||||
}
|
||||
|
||||
.body-content{
|
||||
padding-top: 70px;
|
||||
padding-bottom: 70px;
|
||||
}
|
||||
|
||||
footer, .push {
|
||||
height: 60px; /* .push must be the same height as .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;
|
||||
}
|
||||
|
|
44
index.html
44
index.html
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="index-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#django-rest-framework">Django REST framework</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#django-rest-framework">Django REST framework</a></li>
|
||||
<li><a href="#requirements">Requirements</a></li>
|
||||
<li><a href="#installation">Installation</a></li>
|
||||
<li><a href="#quickstart">Quickstart</a></li>
|
||||
|
@ -109,12 +110,12 @@
|
|||
<li><a href="#development">Development</a></li>
|
||||
<li><a href="#license">License</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<iframe src="http://ghbtns.com/github-btn.html?user=tomchristie&repo=django-rest-framework&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>
|
||||
<div id="main-content" class="span9">
|
||||
<iframe src="http://ghbtns.com/github-btn.html?user=tomchristie&repo=django-rest-framework&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>
|
||||
|
||||
<p><a href="http://travis-ci.org/tomchristie/django-rest-framework?branch=restframework2"><img alt="Travis build image" src="https://secure.travis-ci.org/tomchristie/django-rest-framework.png?branch=restframework2" /></a></p>
|
||||
<h1 id="django-rest-framework">Django REST framework</h1>
|
||||
|
@ -229,20 +230,17 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
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.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="browsable-api-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,25 +93,24 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#working-with-the-browsable-api">Working with the Browsable API</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#working-with-the-browsable-api">Working with the Browsable API</a></li>
|
||||
<li><a href="#urls">URLs</a></li>
|
||||
<li><a href="#formats">Formats</a></li>
|
||||
<li><a href="#customizing">Customizing</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="working-with-the-browsable-api">Working with the Browsable API</h1>
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="working-with-the-browsable-api">Working with the Browsable API</h1>
|
||||
<p>API may stand for Application <em>Programming</em> Interface, but humans have to be able to read the APIs, too; someone has to do the programming. Django REST Framework supports generating human-friendly HTML output for each resource when the <code>HTML</code> format is requested. These pages allow for easy browsing of resources, as well as forms for submitting data to the resources using <code>POST</code>, <code>PUT</code>, and <code>DELETE</code>.</p>
|
||||
<h2 id="urls">URLs</h2>
|
||||
<p>If you include fully-qualified URLs in your resource output, they will be 'urlized' and made clickable for easy browsing by humans. The <code>rest_framework</code> package includes a <a href="../api-guide/reverse"><code>reverse</code></a> helper for this purpose.</p>
|
||||
|
@ -169,20 +170,17 @@
|
|||
</ul>
|
||||
<h4 id="not-using-basehtml">Not using base.html</h4>
|
||||
<p>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 <code>api.html</code> extend <code>base.html</code>. Then the page content and capabilities are entirely up to you.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="changelog-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li><a href="#200">2.0.0</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li><a href="#200">2.0.0</a></li>
|
||||
<li><a href="#040">0.4.0</a></li>
|
||||
<li><a href="#033">0.3.3</a></li>
|
||||
<li><a href="#032">0.3.2</a></li>
|
||||
|
@ -113,12 +114,12 @@
|
|||
<li><a href="#011">0.1.1</a></li>
|
||||
<li><a href="#010">0.1.0</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="release-notes">Release Notes</h1>
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="release-notes">Release Notes</h1>
|
||||
<h2 id="200">2.0.0</h2>
|
||||
<p><strong>TODO:</strong> Explain REST framework 2.0</p>
|
||||
<h2 id="040">0.4.0</h2>
|
||||
|
@ -231,20 +232,17 @@
|
|||
<ul>
|
||||
<li>Initial release.</li>
|
||||
</ul>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="contributing-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,25 +93,24 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#contributing-to-rest-framework">Contributing to REST framework</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#contributing-to-rest-framework">Contributing to REST framework</a></li>
|
||||
<li><a href="#running-the-tests">Running the tests</a></li>
|
||||
<li><a href="#building-the-docs">Building the docs</a></li>
|
||||
<li><a href="#managing-compatibility-issues">Managing compatibility issues</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="contributing-to-rest-framework">Contributing to REST framework</h1>
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="contributing-to-rest-framework">Contributing to REST framework</h1>
|
||||
<blockquote>
|
||||
<p>The world can only really be changed one piece at a time. The art is picking that piece.</p>
|
||||
<p>— <a href="http://www.w3.org/People/Berners-Lee/FAQ.html">Tim Berners-Lee</a></p>
|
||||
|
@ -118,20 +119,17 @@
|
|||
<h2 id="building-the-docs">Building the docs</h2>
|
||||
<h2 id="managing-compatibility-issues">Managing compatibility issues</h2>
|
||||
<p><strong>Describe compat module</strong></p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="credits-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,24 +93,23 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#credits">Credits</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#credits">Credits</a></li>
|
||||
<li><a href="#additional-thanks">Additional thanks</a></li>
|
||||
<li><a href="#contact">Contact</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="credits">Credits</h1>
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="credits">Credits</h1>
|
||||
<p>The following people have helped make REST framework great.</p>
|
||||
<ul>
|
||||
<li>Tom Christie - <a href="https://github.com/tomchristie">tomchristie</a> </li>
|
||||
|
@ -167,20 +168,17 @@
|
|||
<li>twitter: <a href="http://twitter.com/_tomchristie">@_tomchristie</a></li>
|
||||
<li>email: <a href="mailto:tom@tomchristie.com">tom@tomchristie.com</a></li>
|
||||
</ul>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="csrf-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,22 +93,21 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#working-with-ajax-and-csrf">Working with AJAX and CSRF</a></li>
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#working-with-ajax-and-csrf">Working with AJAX and CSRF</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="working-with-ajax-and-csrf">Working with AJAX and CSRF</h1>
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="working-with-ajax-and-csrf">Working with AJAX and CSRF</h1>
|
||||
<blockquote>
|
||||
<p>"Take a close look at possible CSRF / XSRF vulnerabilities on your own websites. They're the worst kind of vulnerability -- very easy to exploit by attackers, yet not so intuitively easy to understand for software developers, at least until you've been bitten by one."</p>
|
||||
<p>— <a href="http://www.codinghorror.com/blog/2008/10/preventing-csrf-and-xsrf-attacks.html">Jeff Atwood</a></p>
|
||||
|
@ -116,20 +117,17 @@
|
|||
<li>Explain defered CSRF style used by REST framework</li>
|
||||
<li>Why you should use Django's standard login/logout views, and not REST framework view</li>
|
||||
</ul>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="formoverloading-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,27 +93,26 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#browser-hacks">Browser hacks</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#browser-hacks">Browser hacks</a></li>
|
||||
<li><a href="#browser-based-put,-delete,-etc">Browser based PUT, DELETE, etc...</a></li>
|
||||
<li><a href="#browser-based-submission-of-non-form-content">Browser based submission of non-form content</a></li>
|
||||
<li><a href="#url-based-accept-headers">URL based accept headers</a></li>
|
||||
<li><a href="#url-based-format-suffixes">URL based format suffixes</a></li>
|
||||
<li><a href="#doesnt-html5-support-put-and-delete-forms">Doesn't HTML5 support PUT and DELETE forms?</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="browser-hacks">Browser hacks</h1>
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="browser-hacks">Browser hacks</h1>
|
||||
<blockquote>
|
||||
<p>"There are two noncontroversial uses for overloaded POST. The first is to <em>simulate</em> HTTP's uniform interface for clients like web browsers that don't support PUT or DELETE"</p>
|
||||
<p>— <a href="1">RESTful Web Services</a>, Leonard Richardson & Sam Ruby.</p>
|
||||
|
@ -137,20 +138,17 @@
|
|||
<h2 id="url-based-format-suffixes">URL based format suffixes</h2>
|
||||
<h2 id="doesnt-html5-support-put-and-delete-forms">Doesn't HTML5 support PUT and DELETE forms?</h2>
|
||||
<p>Nope. It was at one point intended to support <code>PUT</code> and <code>DELETE</code> forms, but was later <a href="3">dropped from the spec</a>. There remains <a href="4">ongoing discussion</a> about adding support for <code>PUT</code> and <code>DELETE</code>, as well as how to support content types other than form-encoded data.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="rest-hypermedia-hateoas-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,23 +93,22 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#rest,-hypermedia-&-hateoas">REST, Hypermedia & HATEOAS</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#rest,-hypermedia-&-hateoas">REST, Hypermedia & HATEOAS</a></li>
|
||||
<li class="main"><a href="#building-hypermedia-apis-with-rest-framework">Building Hypermedia APIs with REST framework</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</h1>
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</h1>
|
||||
<blockquote>
|
||||
<p>You keep using that word "REST". I do not think it means what you think it means.</p>
|
||||
<p>— Mike Amundsen, <a href="http://vimeo.com/channels/restfest/page:2">REST fest 2012 keynote</a>.</p>
|
||||
|
@ -132,20 +133,17 @@ the Design of Network-based Software Architectures</a>.</li>
|
|||
<p>REST framework also includes <a href="../api-guide/serializers">serialization</a> and <a href="../api-guide/parsers">parser</a>/<a href="../api-guide/renderers">renderer</a> components that make it easy to build appropriate media types, <a href="../api-guide/fields">hyperlinked relations</a> for building well-connected systems, and great support for <a href="../api-guide/content-negotiation">content negotiation</a>.</p>
|
||||
<h3 id="what-rest-framework-doesnt-provide">What REST framework <em>doesn't</em> provide.</h3>
|
||||
<p>What REST framework doesn't do is give you is machine readable hypermedia formats such as <a href="http://www.amundsen.com/media-types/collection/">Collection+JSON</a> 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.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="1-serialization-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#tutorial-1-serialization">Tutorial 1: Serialization</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#tutorial-1-serialization">Tutorial 1: Serialization</a></li>
|
||||
<li><a href="#introduction">Introduction</a></li>
|
||||
<li><a href="#setting-up-a-new-environment">Setting up a new environment</a></li>
|
||||
<li><a href="#getting-started">Getting started</a></li>
|
||||
|
@ -110,12 +111,12 @@
|
|||
<li><a href="#testing-our-first-attempt-at-a-web-api">Testing our first attempt at a Web API</a></li>
|
||||
<li><a href="#where-are-we-now">Where are we now</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="tutorial-1-serialization">Tutorial 1: Serialization</h1>
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="tutorial-1-serialization">Tutorial 1: Serialization</h1>
|
||||
<h2 id="introduction">Introduction</h2>
|
||||
<p>This tutorial will walk you through the building blocks that make up REST framework. It'll take a little while to get through, but it'll give you a comprehensive understanding of how everything fits together.</p>
|
||||
<h2 id="setting-up-a-new-environment">Setting up a new environment</h2>
|
||||
|
@ -328,20 +329,17 @@ urlpatterns = patterns('blog.views',
|
|||
<p>We're doing okay so far, we've got a serialization API that feels pretty similar to Django's Forms API, and some regular Django views.</p>
|
||||
<p>Our API views don't do anything particularly special at the moment, beyond serve <code>json</code> responses, and there's some error handling edge cases we'd still like to clean up, but it's a functioning Web API.</p>
|
||||
<p>We'll see how we can start to improve things in <a href="2-requests-and-responses">part 2 of the tutorial</a>.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="2-requests-and-responses-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,15 +93,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#tutorial-2-requests-and-responses">Tutorial 2: Requests and Responses</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#tutorial-2-requests-and-responses">Tutorial 2: Requests and Responses</a></li>
|
||||
<li><a href="#request-objects">Request objects</a></li>
|
||||
<li><a href="#response-objects">Response objects</a></li>
|
||||
<li><a href="#status-codes">Status codes</a></li>
|
||||
|
@ -109,12 +110,12 @@
|
|||
<li><a href="#hows-it-looking">How's it looking?</a></li>
|
||||
<li><a href="#whats-next">What's next?</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="tutorial-2-requests-and-responses">Tutorial 2: Requests and Responses</h1>
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="tutorial-2-requests-and-responses">Tutorial 2: Requests and Responses</h1>
|
||||
<p>From this point we're going to really start covering the core of REST framework.
|
||||
Let's introduce a couple of essential building blocks.</p>
|
||||
<h2 id="request-objects">Request objects</h2>
|
||||
|
@ -224,20 +225,17 @@ urlpatterns = format_suffix_patterns(urlpatterns)
|
|||
<p>See the <a href="../topics/browsable-api">browsable api</a> topic for more information about the browsable API feature and how to customize it.</p>
|
||||
<h2 id="whats-next">What's next?</h2>
|
||||
<p>In <a href="3-class-based-views">tutorial part 3</a>, we'll start using class based views, and see how generic views reduce the amount of code we need to write.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="3-class-based-views-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,25 +93,24 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#tutorial-3-class-based-views">Tutorial 3: Class Based Views</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#tutorial-3-class-based-views">Tutorial 3: Class Based Views</a></li>
|
||||
<li><a href="#rewriting-our-api-using-class-based-views">Rewriting our API using class based views</a></li>
|
||||
<li><a href="#using-mixins">Using mixins</a></li>
|
||||
<li><a href="#using-generic-class-based-views">Using generic class based views</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="tutorial-3-class-based-views">Tutorial 3: Class Based Views</h1>
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="tutorial-3-class-based-views">Tutorial 3: Class Based Views</h1>
|
||||
<p>We can also write our API views using class based views, rather than function based views. As we'll see this is a powerful pattern that allows us to reuse common functionality, and helps us keep our code <a href="http://en.wikipedia.org/wiki/Don't_repeat_yourself">DRY</a>.</p>
|
||||
<h2 id="rewriting-our-api-using-class-based-views">Rewriting our API using class based views</h2>
|
||||
<p>We'll start by rewriting the root view as a class based view. All this involves is a little bit of refactoring.</p>
|
||||
|
@ -238,20 +239,17 @@ class CommentInstance(generics.RetrieveUpdateDestroyAPIView):
|
|||
</code></pre>
|
||||
<p>Wow, that's pretty concise. We've got a huge amount for free, and our code looks like good, clean, idiomatic Django.</p>
|
||||
<p>Next we'll move onto <a href="4-authentication-permissions-and-throttling">part 4 of the tutorial</a>, 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.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="4-authentication-permissions-and-throttling-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,37 +93,33 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#tutorial-4-authentication-&-permissions">Tutorial 4: Authentication & Permissions</a></li>
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#tutorial-4-authentication-&-permissions">Tutorial 4: Authentication & Permissions</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="tutorial-4-authentication-permissions">Tutorial 4: Authentication & Permissions</h1>
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="tutorial-4-authentication-permissions">Tutorial 4: Authentication & Permissions</h1>
|
||||
<p>Nothing to see here. Onwards to <a href="5-relationships-and-hyperlinked-apis">part 5</a>.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="5-relationships-and-hyperlinked-apis-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,22 +93,21 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#tutorial-5---relationships-&-hyperlinked-apis">Tutorial 5 - Relationships & Hyperlinked APIs</a></li>
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#tutorial-5---relationships-&-hyperlinked-apis">Tutorial 5 - Relationships & Hyperlinked APIs</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="tutorial-5-relationships-hyperlinked-apis">Tutorial 5 - Relationships & Hyperlinked APIs</h1>
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="tutorial-5-relationships-hyperlinked-apis">Tutorial 5 - Relationships & Hyperlinked APIs</h1>
|
||||
<p><strong>TODO</strong></p>
|
||||
<ul>
|
||||
<li>Create BlogPost model</li>
|
||||
|
@ -114,20 +115,17 @@
|
|||
<li>Demonstrate and describe hyperlinked relationships</li>
|
||||
</ul>
|
||||
<p>Onwards to <a href="6-resource-orientated-projects">part 6</a>.</p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<![endif]-->
|
||||
<body onload="prettyPrint()" class="6-resource-orientated-projects-page">
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
|
@ -91,27 +93,26 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrap">
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#tutorial-6---resources">Tutorial 6 - Resources</a></li>
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
<li class="main"><a href="#tutorial-6---resources">Tutorial 6 - Resources</a></li>
|
||||
<li><a href="#refactoring-to-use-resources,-not-views">Refactoring to use Resources, not Views</a></li>
|
||||
<li><a href="#binding-resources-to-urls-explicitly">Binding Resources to URLs explicitly</a></li>
|
||||
<li><a href="#using-routers">Using Routers</a></li>
|
||||
<li><a href="#trade-offs-between-views-vs-resources">Trade-offs between views vs resources.</a></li>
|
||||
<li><a href="#onwards-and-upwards">Onwards and upwards.</a></li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="tutorial-6-resources">Tutorial 6 - Resources</h1>
|
||||
<div id="main-content" class="span9">
|
||||
<h1 id="tutorial-6-resources">Tutorial 6 - Resources</h1>
|
||||
<p>Resource classes are just View classes that don't have any handler methods bound to them. The actions on a resource are defined, </p>
|
||||
<p>This allows us to:</p>
|
||||
<ul>
|
||||
|
@ -173,20 +174,17 @@ urlpatterns = router.urlpatterns
|
|||
<li>Follow me <a href="https://twitter.com/_tomchristie">on Twitter</a> and say hi.</li>
|
||||
</ul>
|
||||
<p><strong>Now go build some awesome things.</strong></p>
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
</div><!--/.fluid-container-->
|
||||
</div><!--/.body content-->
|
||||
|
||||
<div id="push"></div>
|
||||
</div>
|
||||
</div><!--/.wrapper -->
|
||||
|
||||
<!--
|
||||
<div class="row footer">
|
||||
<div class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<footer class="span12">
|
||||
<p>Sponsored by <a href="http://dabapps.com/">Dab Apps</a>.</a></p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
|
|
Loading…
Reference in New Issue
Block a user