mirror of
https://github.com/encode/django-rest-framework.git
synced 2026-02-14 03:00:34 +03:00
Update documentation
This commit is contained in:
parent
774a21a72b
commit
8a0f235e1a
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Authentication</title>
|
||||
<title>Authentication - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/authentication/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../permissions/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../permissions">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../validators/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../validators">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Authentication</a>
|
||||
<a href=".">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -469,14 +465,14 @@
|
|||
<p>Auth needs to be pluggable.</p>
|
||||
<p>— Jacob Kaplan-Moss, <a href="http://jacobian.org/writing/rest-worst-practices/">"REST worst practices"</a></p>
|
||||
</blockquote>
|
||||
<p>Authentication is the mechanism of associating an incoming request with a set of identifying credentials, such as the user the request came from, or the token that it was signed with. The <a href="../permissions/">permission</a> and <a href="../throttling/">throttling</a> policies can then use those credentials to determine if the request should be permitted.</p>
|
||||
<p>Authentication is the mechanism of associating an incoming request with a set of identifying credentials, such as the user the request came from, or the token that it was signed with. The <a href="../permissions">permission</a> and <a href="../throttling">throttling</a> policies can then use those credentials to determine if the request should be permitted.</p>
|
||||
<p>REST framework provides a number of authentication schemes out of the box, and also allows you to implement custom schemes.</p>
|
||||
<p>Authentication is always run at the very start of the view, before the permission and throttling checks occur, and before any other code is allowed to proceed.</p>
|
||||
<p>The <code>request.user</code> property will typically be set to an instance of the <code>contrib.auth</code> package's <code>User</code> class.</p>
|
||||
<p>The <code>request.auth</code> property is used for any additional authentication information, for example, it may be used to represent an authentication token that the request was signed with.</p>
|
||||
<hr />
|
||||
<p><strong>Note:</strong> Don't forget that <strong>authentication by itself won't allow or disallow an incoming request</strong>, it simply identifies the credentials that the request was made with.</p>
|
||||
<p>For information on how to setup the permission polices for your API please see the <a href="../permissions/">permissions documentation</a>.</p>
|
||||
<p>For information on how to setup the permission polices for your API please see the <a href="../permissions">permissions documentation</a>.</p>
|
||||
<hr />
|
||||
<h2 id="how-authentication-is-determined">How authentication is determined</h2>
|
||||
<p>The authentication schemes are always defined as a list of classes. REST framework will attempt to authenticate with each class in the list, and will set <code>request.user</code> and <code>request.auth</code> using the return value of the first class that successfully authenticates.</p>
|
||||
|
|
@ -717,6 +713,7 @@ REST_FRAMEWORK = {
|
|||
<p><a href="https://github.com/sunscrapers/djoser">Djoser</a> library provides a set of views to handle basic actions such as registration, login, logout, password reset and account activation. The package works with a custom user model and it uses token based authentication. This is a ready to use REST implementation of Django authentication system.</p>
|
||||
<h2 id="django-rest-auth">django-rest-auth</h2>
|
||||
<p><a href="https://github.com/Tivix/django-rest-auth">Django-rest-auth</a> library provides a set of REST API endpoints for registration, authentication (including social media authentication), password reset, retrieve and update user details, etc. By having these API endpoints, your client apps such as AngularJS, iOS, Android, and others can communicate to your Django backend site independently via REST APIs for user management.</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Content negotiation</title>
|
||||
<title>Content negotiation - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/content-negotiation/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../metadata/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../metadata">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../versioning/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../versioning">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Content negotiation</a>
|
||||
<a href=".">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -464,6 +460,7 @@ class NoNegotiationView(APIView):
|
|||
'accepted media type': request.accepted_renderer.media_type
|
||||
})
|
||||
</code></pre>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Exceptions</title>
|
||||
<title>Exceptions - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/exceptions/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../status-codes/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../status-codes">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../reverse/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../reverse">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Exceptions</a>
|
||||
<a href=".">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -522,11 +518,11 @@ class ServiceUnavailable(APIException):
|
|||
<h2 id="authenticationfailed">AuthenticationFailed</h2>
|
||||
<p><strong>Signature:</strong> <code>AuthenticationFailed(detail=None)</code></p>
|
||||
<p>Raised when an incoming request includes incorrect authentication.</p>
|
||||
<p>By default this exception results in a response with the HTTP status code "401 Unauthenticated", but it may also result in a "403 Forbidden" response, depending on the authentication scheme in use. See the <a href="../authentication/">authentication documentation</a> for more details.</p>
|
||||
<p>By default this exception results in a response with the HTTP status code "401 Unauthenticated", but it may also result in a "403 Forbidden" response, depending on the authentication scheme in use. See the <a href="../authentication">authentication documentation</a> for more details.</p>
|
||||
<h2 id="notauthenticated">NotAuthenticated</h2>
|
||||
<p><strong>Signature:</strong> <code>NotAuthenticated(detail=None)</code></p>
|
||||
<p>Raised when an unauthenticated request fails the permission checks.</p>
|
||||
<p>By default this exception results in a response with the HTTP status code "401 Unauthenticated", but it may also result in a "403 Forbidden" response, depending on the authentication scheme in use. See the <a href="../authentication/">authentication documentation</a> for more details.</p>
|
||||
<p>By default this exception results in a response with the HTTP status code "401 Unauthenticated", but it may also result in a "403 Forbidden" response, depending on the authentication scheme in use. See the <a href="../authentication">authentication documentation</a> for more details.</p>
|
||||
<h2 id="permissiondenied">PermissionDenied</h2>
|
||||
<p><strong>Signature:</strong> <code>PermissionDenied(detail=None)</code></p>
|
||||
<p>Raised when an authenticated request fails the permission checks.</p>
|
||||
|
|
@ -564,6 +560,7 @@ class ServiceUnavailable(APIException):
|
|||
</code></pre>
|
||||
<p>The generic views use the <code>raise_exception=True</code> flag, which means that you can override the style of validation error responses globally in your API. To do so, use a custom exception handler, as described above.</p>
|
||||
<p>By default this exception results in a response with the HTTP status code "400 Bad Request".</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Serializer fields</title>
|
||||
<title>Serializer fields - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/fields/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../relations/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../relations">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../serializers/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../serializers">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Serializer fields</a>
|
||||
<a href=".">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -858,7 +854,7 @@ Django's regular <a href="https://docs.djangoproject.com/en/dev/ref/settings/#st
|
|||
<pre><code>modified = serializers.HiddenField(default=timezone.now)
|
||||
</code></pre>
|
||||
<p>The <code>HiddenField</code> class is usually only needed if you have some validation that needs to run based on some pre-provided field values, but you do not want to expose all of those fields to the end user.</p>
|
||||
<p>For further examples on <code>HiddenField</code> see the <a href="../validators/">validators</a> documentation.</p>
|
||||
<p>For further examples on <code>HiddenField</code> see the <a href="../validators">validators</a> documentation.</p>
|
||||
<h2 id="modelfield">ModelField</h2>
|
||||
<p>A generic field that can be tied to any arbitrary model field. The <code>ModelField</code> class delegates the task of serialization/deserialization to its associated model field. This field can be used to create serializer fields for custom model fields, without having to create a new custom serializer field.</p>
|
||||
<p>This field is used by <code>ModelSerializer</code> to correspond to custom model field classes.</p>
|
||||
|
|
@ -982,6 +978,7 @@ def to_internal_value(self, data):
|
|||
<p>The <a href="https://github.com/djangonauts/django-rest-framework-gis">django-rest-framework-gis</a> package provides geographic addons for django rest framework like a <code>GeometryField</code> field and a GeoJSON serializer.</p>
|
||||
<h2 id="django-rest-framework-hstore">django-rest-framework-hstore</h2>
|
||||
<p>The <a href="https://github.com/djangonauts/django-rest-framework-hstore">django-rest-framework-hstore</a> package provides an <code>HStoreField</code> to support <a href="https://github.com/djangonauts/django-hstore">django-hstore</a> <code>DictionaryField</code> model field.</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Filtering</title>
|
||||
<title>Filtering - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/filtering/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../pagination/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../pagination">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../throttling/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../throttling">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Filtering</a>
|
||||
<a href=".">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -761,6 +757,7 @@ class ProductFilter(django_filters.FilterSet):
|
|||
<p>The <a href="https://github.com/philipn/django-rest-framework-filters">django-rest-framework-filters package</a> works together with the <code>DjangoFilterBackend</code> class, and allows you to easily create filters across relationships, or create multiple filter lookup types for a given field.</p>
|
||||
<h2 id="django-rest-framework-full-word-search-filter">Django REST framework full word search filter</h2>
|
||||
<p>The <a href="https://github.com/trollknurr/django-rest-framework-word-search-filter">djangorestframework-word-filter</a> developed as alternative to <code>filters.SearchFilter</code> which will search full word in text, or exact match.</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Format suffixes</title>
|
||||
<title>Format suffixes - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/format-suffixes/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../reverse/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../reverse">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../metadata/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../metadata">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Format suffixes</a>
|
||||
<a href=".">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -440,6 +436,7 @@ urlpatterns = i18n_patterns(
|
|||
<p>It is actually a misconception. For example, take the following quote from Roy Fielding discussing the relative merits of query parameter media-type indicators vs. file extension media-type indicators:</p>
|
||||
<p>“That's why I always prefer extensions. Neither choice has anything to do with REST.” — Roy Fielding, <a href="http://tech.groups.yahoo.com/group/rest-discuss/message/14844">REST discuss mailing list</a></p>
|
||||
<p>The quote does not mention Accept headers, but it does make it clear that format suffixes should be considered an acceptable pattern.</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Generic views</title>
|
||||
<title>Generic views - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/generic-views/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../viewsets/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../viewsets">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../views/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../views">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Generic views</a>
|
||||
<a href=".">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -760,6 +756,7 @@ class BaseRetrieveUpdateDestroyView(MultipleFieldLookupMixin,
|
|||
<p>The following third party packages provide additional generic view implementations.</p>
|
||||
<h2 id="django-rest-framework-bulk">Django REST Framework bulk</h2>
|
||||
<p>The <a href="https://github.com/miki725/django-rest-framework-bulk">django-rest-framework-bulk package</a> implements generic view mixins as well as some common concrete generic views to allow to apply bulk operations via API requests.</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Metadata</title>
|
||||
<title>Metadata - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/metadata/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../format-suffixes/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../format-suffixes">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../content-negotiation/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../content-negotiation">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Metadata</a>
|
||||
<a href=".">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -472,6 +468,7 @@ def schema(self, request):
|
|||
'description': view.get_view_description()
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Pagination</title>
|
||||
<title>Pagination - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/pagination/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../versioning/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../versioning">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../filtering/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../filtering">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Pagination</a>
|
||||
<a href=".">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -656,7 +652,7 @@ class StandardResultsSetPagination(PageNumberPagination):
|
|||
</code></pre>
|
||||
<p>API responses for list endpoints will now include a <code>Link</code> header, instead of including the pagination links as part of the body of the response, for example:</p>
|
||||
<hr />
|
||||
<p><img alt="Link Header" src="../../img/link-header-pagination.png" /></p>
|
||||
<p><img alt="Link Header" src="../../../img/link-header-pagination.png" /></p>
|
||||
<p><em>A custom pagination style, using the 'Link' header'</em></p>
|
||||
<hr />
|
||||
<h1 id="html-pagination-controls">HTML pagination controls</h1>
|
||||
|
|
@ -677,6 +673,7 @@ class StandardResultsSetPagination(PageNumberPagination):
|
|||
<p>The following third party packages are also available.</p>
|
||||
<h2 id="drf-extensions">DRF-extensions</h2>
|
||||
<p>The <a href="http://chibisov.github.io/drf-extensions/docs/"><code>DRF-extensions</code> package</a> includes a <a href="http://chibisov.github.io/drf-extensions/docs/#paginatebymaxmixin"><code>PaginateByMaxMixin</code> mixin class</a> that allows your API clients to specify <code>?page_size=max</code> to obtain the maximum allowed page size.</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Parsers</title>
|
||||
<title>Parsers - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/parsers/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../renderers/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../renderers">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../routers/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../routers">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Parsers</a>
|
||||
<a href=".">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -600,6 +596,7 @@ def parse(self, stream, media_type=None, parser_context=None):
|
|||
<p><a href="https://github.com/juanriaza/django-rest-framework-msgpack">MessagePack</a> is a fast, efficient binary serialization format. <a href="https://github.com/juanriaza">Juan Riaza</a> maintains the <a href="https://github.com/juanriaza/django-rest-framework-msgpack">djangorestframework-msgpack</a> package which provides MessagePack renderer and parser support for REST framework.</p>
|
||||
<h2 id="camelcase-json">CamelCase JSON</h2>
|
||||
<p><a href="https://github.com/vbabiy/djangorestframework-camel-case">djangorestframework-camel-case</a> provides camel case JSON renderers and parsers for REST framework. This allows serializers to use Python-style underscored field names, but be exposed in the API as Javascript-style camel case field names. It is maintained by <a href="https://github.com/vbabiy">Vitaly Babiy</a>.</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Permissions</title>
|
||||
<title>Permissions - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/permissions/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../throttling/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../throttling">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../authentication/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../authentication">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Permissions</a>
|
||||
<a href=".">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -457,7 +453,7 @@
|
|||
<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>
|
||||
<p>— <a href="https://developer.apple.com/library/mac/#documentation/security/Conceptual/AuthenticationAndAuthorizationGuide/Authorization/Authorization.html">Apple Developer Documentation</a></p>
|
||||
</blockquote>
|
||||
<p>Together with <a href="../authentication/">authentication</a> and <a href="../throttling/">throttling</a>, permissions determine whether a request should be granted or denied access.</p>
|
||||
<p>Together with <a href="../authentication">authentication</a> and <a href="../throttling">throttling</a>, permissions determine whether a request should be granted or denied access.</p>
|
||||
<p>Permission checks are always run at the very start of the view, before any other code is allowed to proceed. Permission checks will typically use the authentication information in the <code>request.user</code> and <code>request.auth</code> properties to determine if the incoming request should be permitted.</p>
|
||||
<p>Permissions are used to grant or deny access different classes of users to different parts of the API.</p>
|
||||
<p>The simplest style of permission would be to allow access to any authenticated user, and deny access to any unauthenticated user. This corresponds the <code>IsAuthenticated</code> class in REST framework.</p>
|
||||
|
|
@ -487,7 +483,7 @@ or if you override the <code>get_object</code> method on a generic view, then yo
|
|||
</code></pre>
|
||||
<h4 id="limitations-of-object-level-permissions">Limitations of object level permissions</h4>
|
||||
<p>For performance reasons the generic views will not automatically apply object level permissions to each instance in a queryset when returning a list of objects.</p>
|
||||
<p>Often when you're using object level permissions you'll also want to <a href="../filtering/">filter the queryset</a> appropriately, to ensure that users only have visibility onto instances that they are permitted to view.</p>
|
||||
<p>Often when you're using object level permissions you'll also want to <a href="../filtering">filter the queryset</a> appropriately, to ensure that users only have visibility onto instances that they are permitted to view.</p>
|
||||
<h2 id="setting-the-permission-policy">Setting the permission policy</h2>
|
||||
<p>The default permission policy may be set globally, using the <code>DEFAULT_PERMISSION_CLASSES</code> setting. For example.</p>
|
||||
<pre><code>REST_FRAMEWORK = {
|
||||
|
|
@ -615,7 +611,7 @@ class BlacklistPermission(permissions.BasePermission):
|
|||
return obj.owner == request.user
|
||||
</code></pre>
|
||||
<p>Note that the generic views will check the appropriate object level permissions, but if you're writing your own custom views, you'll need to make sure you check the object level permission checks yourself. You can do so by calling <code>self.check_object_permissions(request, obj)</code> from the view once you have the object instance. This call will raise an appropriate <code>APIException</code> if any object-level permission checks fail, and will otherwise simply return.</p>
|
||||
<p>Also note that the generic views will only check the object-level permissions for views that retrieve a single model instance. If you require object-level filtering of list views, you'll need to filter the queryset separately. See the <a href="../filtering/">filtering documentation</a> for more details.</p>
|
||||
<p>Also note that the generic views will only check the object-level permissions for views that retrieve a single model instance. If you require object-level filtering of list views, you'll need to filter the queryset separately. See the <a href="../filtering">filtering documentation</a> for more details.</p>
|
||||
<hr />
|
||||
<h1 id="third-party-packages">Third party packages</h1>
|
||||
<p>The following third party packages are also available.</p>
|
||||
|
|
@ -625,6 +621,7 @@ class BlacklistPermission(permissions.BasePermission):
|
|||
<p>The <a href="https://github.com/niwibe/djangorestframework-composed-permissions">Composed Permissions</a> package provides a simple way to define complex and multi-depth (with logic operators) permission objects, using small and reusable components.</p>
|
||||
<h2 id="rest-condition">REST Condition</h2>
|
||||
<p>The <a href="https://github.com/caxap/rest_condition">REST Condition</a> package is another extension for building complex permissions in a simple and convenient way. The extension allows you to combine permissions with logical operators.</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Serializer relations</title>
|
||||
<title>Serializer relations - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/relations/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../validators/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../validators">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../fields/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../fields">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Serializer relations</a>
|
||||
<a href=".">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -844,6 +840,7 @@ attributes are not configured to correctly match the URL conf.</p>
|
|||
<p>The following third party packages are also available.</p>
|
||||
<h2 id="drf-nested-routers">DRF Nested Routers</h2>
|
||||
<p>The <a href="https://github.com/alanjds/drf-nested-routers">drf-nested-routers package</a> provides routers and relationship fields for working with nested resources.</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Renderers</title>
|
||||
<title>Renderers - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/renderers/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../serializers/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../serializers">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../parsers/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../parsers">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Renderers</a>
|
||||
<a href=".">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -517,7 +513,7 @@
|
|||
<h2 id="how-the-renderer-is-determined">How the renderer is determined</h2>
|
||||
<p>The set of valid renderers for a view is always defined as a list of classes. When a view is entered REST framework will perform content negotiation on the incoming request, and determine the most appropriate renderer to satisfy the request.</p>
|
||||
<p>The basic process of content negotiation involves examining the request's <code>Accept</code> header, to determine which media types it expects in the response. Optionally, format suffixes on the URL may be used to explicitly request a particular representation. For example the URL <code>http://example.com/api/users_count.json</code> might be an endpoint that always returns JSON data.</p>
|
||||
<p>For more information see the documentation on <a href="../content-negotiation/">content negotiation</a>.</p>
|
||||
<p>For more information see the documentation on <a href="../content-negotiation">content negotiation</a>.</p>
|
||||
<h2 id="setting-the-renderers">Setting the renderers</h2>
|
||||
<p>The default set of renderers may be set globally, using the <code>DEFAULT_RENDERER_CLASSES</code> setting. For example, the following settings would use <code>JSON</code> as the main media type and also include the self describing API.</p>
|
||||
<pre><code>REST_FRAMEWORK = {
|
||||
|
|
@ -639,7 +635,7 @@ def simple_html_view(request):
|
|||
return JSONRenderer()
|
||||
</code></pre>
|
||||
<h2 id="multipartrenderer">MultiPartRenderer</h2>
|
||||
<p>This renderer is used for rendering HTML multipart form data. <strong>It is not suitable as a response renderer</strong>, but is instead used for creating test requests, using REST framework's <a href="../testing/">test client and test request factory</a>.</p>
|
||||
<p>This renderer is used for rendering HTML multipart form data. <strong>It is not suitable as a response renderer</strong>, but is instead used for creating test requests, using REST framework's <a href="../testing">test client and test request factory</a>.</p>
|
||||
<p><strong>.media_type</strong>: <code>multipart/form-data; boundary=BoUnDaRyStRiNg</code></p>
|
||||
<p><strong>.format</strong>: <code>'.multipart'</code></p>
|
||||
<p><strong>.charset</strong>: <code>utf-8</code></p>
|
||||
|
|
@ -807,6 +803,7 @@ In this case you can underspecify the media types it should respond to, by using
|
|||
<p><a href="https://github.com/vbabiy/djangorestframework-camel-case">djangorestframework-camel-case</a> provides camel case JSON renderers and parsers for REST framework. This allows serializers to use Python-style underscored field names, but be exposed in the API as Javascript-style camel case field names. It is maintained by <a href="https://github.com/vbabiy">Vitaly Babiy</a>.</p>
|
||||
<h2 id="pandas-csv-excel-png">Pandas (CSV, Excel, PNG)</h2>
|
||||
<p><a href="https://github.com/wq/django-rest-pandas">Django REST Pandas</a> provides a serializer and renderers that support additional data processing and output via the <a href="http://pandas.pydata.org/">Pandas</a> DataFrame API. Django REST Pandas includes renderers for Pandas-style CSV files, Excel workbooks (both <code>.xls</code> and <code>.xlsx</code>), and a number of <a href="https://github.com/wq/django-rest-pandas#supported-formats">other formats</a>. It is maintained by <a href="https://github.com/sheppard">S. Andrew Sheppard</a> as part of the <a href="https://github.com/wq">wq Project</a>.</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Requests</title>
|
||||
<title>Requests - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/requests/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../responses/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../responses">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../../tutorial/6-viewsets-and-routers/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../../tutorial/6-viewsets-and-routers">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Requests</a>
|
||||
<a href=".">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -480,7 +476,7 @@
|
|||
<li>It supports parsing the content of HTTP methods other than <code>POST</code>, meaning that you can access the content of <code>PUT</code> and <code>PATCH</code> requests.</li>
|
||||
<li>It supports REST framework's flexible request parsing, rather than just supporting form data. For example you can handle incoming JSON data in the same way that you handle incoming form data.</li>
|
||||
</ul>
|
||||
<p>For more details see the <a href="../parsers/">parsers documentation</a>.</p>
|
||||
<p>For more details see the <a href="../parsers">parsers documentation</a>.</p>
|
||||
<h2 id="query_params">.query_params</h2>
|
||||
<p><code>request.query_params</code> is a more correctly named synonym for <code>request.GET</code>.</p>
|
||||
<p>For clarity inside your code, we recommend using <code>request.query_params</code> instead of the Django's standard <code>request.GET</code>. Doing so will help keep your codebase more correct and obvious - any HTTP method type may include query parameters, not just <code>GET</code> requests.</p>
|
||||
|
|
@ -512,11 +508,11 @@
|
|||
<h2 id="user">.user</h2>
|
||||
<p><code>request.user</code> typically returns an instance of <code>django.contrib.auth.models.User</code>, although the behavior depends on the authentication policy being used.</p>
|
||||
<p>If the request is unauthenticated the default value of <code>request.user</code> is an instance of <code>django.contrib.auth.models.AnonymousUser</code>.</p>
|
||||
<p>For more details see the <a href="../authentication/">authentication documentation</a>.</p>
|
||||
<p>For more details see the <a href="../authentication">authentication documentation</a>.</p>
|
||||
<h2 id="auth">.auth</h2>
|
||||
<p><code>request.auth</code> returns any additional authentication context. The exact behavior of <code>request.auth</code> depends on the authentication policy being used, but it may typically be an instance of the token that the request was authenticated against.</p>
|
||||
<p>If the request is unauthenticated, or if no additional context is present, the default value of <code>request.auth</code> is <code>None</code>.</p>
|
||||
<p>For more details see the <a href="../authentication/">authentication documentation</a>.</p>
|
||||
<p>For more details see the <a href="../authentication">authentication documentation</a>.</p>
|
||||
<h2 id="authenticators">.authenticators</h2>
|
||||
<p>The <code>APIView</code> class or <code>@api_view</code> decorator will ensure that this property is automatically set to a list of <code>Authentication</code> instances, based on the <code>authentication_classes</code> set on the view or based on the <code>DEFAULT_AUTHENTICATORS</code> setting.</p>
|
||||
<p>You won't typically need to access this property.</p>
|
||||
|
|
@ -526,21 +522,22 @@
|
|||
<h2 id="method">.method</h2>
|
||||
<p><code>request.method</code> returns the <strong>uppercased</strong> string representation of the request's HTTP method.</p>
|
||||
<p>Browser-based <code>PUT</code>, <code>PATCH</code> and <code>DELETE</code> forms are transparently supported.</p>
|
||||
<p>For more information see the <a href="../../topics/browser-enhancements/">browser enhancements documentation</a>.</p>
|
||||
<p>For more information see the <a href="../../topics/browser-enhancements">browser enhancements documentation</a>.</p>
|
||||
<h2 id="content_type">.content_type</h2>
|
||||
<p><code>request.content_type</code>, returns a string object representing the media type of the HTTP request's body, or an empty string if no media type was provided.</p>
|
||||
<p>You won't typically need to directly access the request's content type, as you'll normally rely on REST framework's default request parsing behavior.</p>
|
||||
<p>If you do need to access the content type of the request you should use the <code>.content_type</code> property in preference to using <code>request.META.get('HTTP_CONTENT_TYPE')</code>, as it provides transparent support for browser-based non-form content.</p>
|
||||
<p>For more information see the <a href="../../topics/browser-enhancements/">browser enhancements documentation</a>.</p>
|
||||
<p>For more information see the <a href="../../topics/browser-enhancements">browser enhancements documentation</a>.</p>
|
||||
<h2 id="stream">.stream</h2>
|
||||
<p><code>request.stream</code> returns a stream representing the content of the request body.</p>
|
||||
<p>You won't typically need to directly access the request's content, as you'll normally rely on REST framework's default request parsing behavior.</p>
|
||||
<p>If you do need to access the raw content directly, you should use the <code>.stream</code> property in preference to using <code>request.content</code>, as it provides transparent support for browser-based non-form content.</p>
|
||||
<p>For more information see the <a href="../../topics/browser-enhancements/">browser enhancements documentation</a>.</p>
|
||||
<p>For more information see the <a href="../../topics/browser-enhancements">browser enhancements documentation</a>.</p>
|
||||
<hr />
|
||||
<h1 id="standard-httprequest-attributes">Standard HttpRequest attributes</h1>
|
||||
<p>As REST framework's <code>Request</code> extends Django's <code>HttpRequest</code>, all the other standard attributes and methods are also available. For example the <code>request.META</code> and <code>request.session</code> dictionaries are available as normal.</p>
|
||||
<p>Note that due to implementation reasons the <code>Request</code> class does not inherit from <code>HttpRequest</code> class, but instead extends the class using composition.</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Responses</title>
|
||||
<title>Responses - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/responses/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../views/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../views">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../requests/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../requests">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Responses</a>
|
||||
<a href=".">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -451,7 +447,7 @@
|
|||
<p>Arguments:</p>
|
||||
<ul>
|
||||
<li><code>data</code>: The serialized data for the response.</li>
|
||||
<li><code>status</code>: A status code for the response. Defaults to 200. See also <a href="../status-codes/">status codes</a>.</li>
|
||||
<li><code>status</code>: A status code for the response. Defaults to 200. See also <a href="../status-codes">status codes</a>.</li>
|
||||
<li><code>template_name</code>: A template name to use if <code>HTMLRenderer</code> is selected.</li>
|
||||
<li><code>headers</code>: A dictionary of HTTP headers to use in the response.</li>
|
||||
<li><code>content_type</code>: The content type of the response. Typically, this will be set automatically by the renderer as determined by content negotiation, but there may be some cases where you need to specify the content type explicitly.</li>
|
||||
|
|
@ -485,6 +481,7 @@ response['Cache-Control'] = 'no-cache'
|
|||
<p><strong>Signature:</strong> <code>.render()</code></p>
|
||||
<p>As with any other <code>TemplateResponse</code>, this method is called to render the serialized data of the response into the final response content. When <code>.render()</code> is called, the response content will be set to the result of calling the <code>.render(data, accepted_media_type, renderer_context)</code> method on the <code>accepted_renderer</code> instance.</p>
|
||||
<p>You won't typically need to call <code>.render()</code> yourself, as it's handled by Django's standard response cycle.</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Returning URLs</title>
|
||||
<title>Returning URLs - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/reverse/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../exceptions/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../exceptions">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../format-suffixes/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../format-suffixes">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Returning URLs</a>
|
||||
<a href=".">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -418,6 +414,7 @@ class APIRootView(APIView):
|
|||
<p>As with the <code>reverse</code> function, you should <strong>include the request as a keyword argument</strong> to the function, for example:</p>
|
||||
<pre><code>api_root = reverse_lazy('api-root', request=request)
|
||||
</code></pre>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Routers</title>
|
||||
<title>Routers - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/routers/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../parsers/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../parsers">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../viewsets/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../viewsets">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Routers</a>
|
||||
<a href=".">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -530,7 +526,7 @@ class UserViewSet(ModelViewSet):
|
|||
<ul>
|
||||
<li>URL pattern: <code>^users/{pk}/change-password/$</code> Name: <code>'user-change-password'</code></li>
|
||||
</ul>
|
||||
<p>For more information see the viewset documentation on <a href="../viewsets/#marking-extra-actions-for-routing">marking extra actions for routing</a>.</p>
|
||||
<p>For more information see the viewset documentation on <a href="../viewsets#marking-extra-actions-for-routing">marking extra actions for routing</a>.</p>
|
||||
<h1 id="api-guide">API Guide</h1>
|
||||
<h2 id="simplerouter">SimpleRouter</h2>
|
||||
<p>This router includes routes for the standard set of <code>list</code>, <code>create</code>, <code>retrieve</code>, <code>update</code>, <code>partial_update</code> and <code>destroy</code> actions. The viewset can also mark additional methods to be routed, using the <code>@detail_route</code> or <code>@list_route</code> decorators.</p>
|
||||
|
|
@ -675,6 +671,7 @@ rest.router.register_model(MyModel)
|
|||
</code></pre>
|
||||
<h2 id="drf-extensions">DRF-extensions</h2>
|
||||
<p>The <a href="http://chibisov.github.io/drf-extensions/docs/"><code>DRF-extensions</code> package</a> provides <a href="http://chibisov.github.io/drf-extensions/docs/#routers">routers</a> for creating <a href="http://chibisov.github.io/drf-extensions/docs/#nested-routes">nested viewsets</a>, <a href="http://chibisov.github.io/drf-extensions/docs/#collection-level-controllers">collection level controllers</a> with <a href="http://chibisov.github.io/drf-extensions/docs/#controller-endpoint-name">customizable endpoint names</a>.</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Serializers</title>
|
||||
<title>Serializers - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/serializers/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../fields/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../fields">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../renderers/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../renderers">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Serializers</a>
|
||||
<a href=".">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -746,7 +742,7 @@ class GameRecord(serializers.Serializer):
|
|||
fields=['room_number', 'date']
|
||||
)
|
||||
</code></pre>
|
||||
<p>For more information see the <a href="../validators/">validators documentation</a>.</p>
|
||||
<p>For more information see the <a href="../validators">validators documentation</a>.</p>
|
||||
<h2 id="accessing-the-initial-data-and-instance">Accessing the initial data and instance</h2>
|
||||
<p>When passing an initial object or queryset to a serializer instance, the object will be made available as <code>.instance</code>. If no initial object is passed then the <code>.instance</code> attribute will be <code>None</code>.</p>
|
||||
<p>When passing data to a serializer instance, the unmodified data will be made available as <code>.initial_data</code>. If the data keyword argument is not passed then the <code>.initial_data</code> attribute will not exist.</p>
|
||||
|
|
@ -865,7 +861,7 @@ serializer.errors
|
|||
has_support_contract=validated_data['profile']['has_support_contract']
|
||||
)
|
||||
</code></pre>
|
||||
<p>For more details on this approach see the Django documentation on <a href="../model-managers">model managers</a>, and <a href="../encapsulation-blogpost">this blogpost on using model and manager classes</a>.</p>
|
||||
<p>For more details on this approach see the Django documentation on <a href="../../model-managers">model managers</a>, and <a href="../../encapsulation-blogpost">this blogpost on using model and manager classes</a>.</p>
|
||||
<h2 id="dealing-with-multiple-objects">Dealing with multiple objects</h2>
|
||||
<p>The <code>Serializer</code> class can also handle serializing or deserializing lists of objects.</p>
|
||||
<h4 id="serializing-multiple-objects">Serializing multiple objects</h4>
|
||||
|
|
@ -963,7 +959,7 @@ AccountSerializer():
|
|||
<p>One example of this is a read-only relation to the currently authenticated <code>User</code> which is <code>unique_together</code> with another identifier. In this case you would declare the user field like so:</p>
|
||||
<pre><code>user = serializers.PrimaryKeyRelatedField(read_only=True, default=serializers.CurrentUserDefault())
|
||||
</code></pre>
|
||||
<p>Please review the <a href="../../api-guide/validators/">Validators Documentation</a> for details on the <a href="../../api-guide/validators/#uniquetogethervalidator">UniqueTogetherValidator</a> and <a href="../../api-guide/validators/#currentuserdefault">CurrentUserDefault</a> classes.</p>
|
||||
<p>Please review the <a href="../..//api-guide/validators/">Validators Documentation</a> for details on the <a href="../..//api-guide/validators/#uniquetogethervalidator">UniqueTogetherValidator</a> and <a href="../..//api-guide/validators/#currentuserdefault">CurrentUserDefault</a> classes.</p>
|
||||
<hr />
|
||||
<h2 id="additional-keyword-arguments">Additional keyword arguments</h2>
|
||||
<p>There is also a shortcut allowing you to specify arbitrary additional keyword arguments on fields, using the <code>extra_kwargs</code> option. Similarly to <code>read_only_fields</code> this means you do not need to explicitly declare the field on the serializer.</p>
|
||||
|
|
@ -986,7 +982,7 @@ AccountSerializer():
|
|||
<h2 id="relational-fields">Relational fields</h2>
|
||||
<p>When serializing model instances, there are a number of different ways you might choose to represent relationships. The default representation for <code>ModelSerializer</code> is to use the primary keys of the related instances.</p>
|
||||
<p>Alternative representations include serializing using hyperlinks, serializing complete nested representations, or serializing with a custom representation.</p>
|
||||
<p>For full details see the <a href="../relations/">serializer relations</a> documentation.</p>
|
||||
<p>For full details see the <a href="../relations">serializer relations</a> documentation.</p>
|
||||
<h2 id="inheritance-of-the-meta-class">Inheritance of the 'Meta' class</h2>
|
||||
<p>The inner <code>Meta</code> class on serializers is not inherited from parent classes by default. This is the same behavior as with Django's <code>Model</code> and <code>ModelForm</code> classes. If you want the <code>Meta</code> class to inherit from a parent class you must do so explicitly. For example:</p>
|
||||
<pre><code>class AccountSerializer(MyBaseSerializer):
|
||||
|
|
@ -1349,6 +1345,7 @@ def all_high_scores(request):
|
|||
<p>The <a href="https://github.com/djangonauts/django-rest-framework-gis">django-rest-framework-gis</a> package provides a <code>GeoFeatureModelSerializer</code> serializer class that supports GeoJSON both for read and write operations.</p>
|
||||
<h2 id="hstoreserializer">HStoreSerializer</h2>
|
||||
<p>The <a href="https://github.com/djangonauts/django-rest-framework-hstore">django-rest-framework-hstore</a> package provides an <code>HStoreSerializer</code> to support <a href="https://github.com/djangonauts/django-hstore">django-hstore</a> <code>DictionaryField</code> model field and its <code>schema-mode</code> feature.</p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Settings</title>
|
||||
<title>Settings - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/settings/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../../topics/documenting-your-api/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../../topics/documenting-your-api">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../testing/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../testing">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Settings</a>
|
||||
<a href=".">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -690,6 +686,7 @@ If set to <code>None</code> then generic filtering is disabled.</p>
|
|||
<h4 id="num_proxies">NUM_PROXIES</h4>
|
||||
<p>An integer of 0 or more, that may be used to specify the number of application proxies that the API runs behind. This allows throttling to more accurately identify client IP addresses. If set to <code>None</code> then less strict IP matching will be used by the throttle classes.</p>
|
||||
<p>Default: <code>None</code></p>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Status codes</title>
|
||||
<title>Status codes - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/status-codes/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../testing/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../testing">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../exceptions/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../exceptions">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Status codes</a>
|
||||
<a href=".">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -490,6 +486,7 @@ is_redirect() # 3xx
|
|||
is_client_error() # 4xx
|
||||
is_server_error() # 5xx
|
||||
</code></pre>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Testing</title>
|
||||
<title>Testing - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/testing/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../settings/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../settings">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../status-codes/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../status-codes">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../throttling/">Throttling</a>
|
||||
<a href="../throttling">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Testing</a>
|
||||
<a href=".">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -654,6 +650,7 @@ self.assertEqual(response.content, '{"username": "lauren", "id": 4}')
|
|||
)
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Throttling</title>
|
||||
<title>Throttling - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/throttling/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../filtering/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../filtering">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../permissions/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../permissions">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../generic-views/">Generic views</a>
|
||||
<a href="../generic-views">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../viewsets/">Viewsets</a>
|
||||
<a href="../viewsets">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../routers/">Routers</a>
|
||||
<a href="../routers">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../parsers/">Parsers</a>
|
||||
<a href="../parsers">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../renderers/">Renderers</a>
|
||||
<a href="../renderers">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../serializers/">Serializers</a>
|
||||
<a href="../serializers">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../fields/">Serializer fields</a>
|
||||
<a href="../fields">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../relations/">Serializer relations</a>
|
||||
<a href="../relations">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../validators/">Validators</a>
|
||||
<a href="../validators">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../authentication/">Authentication</a>
|
||||
<a href="../authentication">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../permissions/">Permissions</a>
|
||||
<a href="../permissions">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Throttling</a>
|
||||
<a href=".">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../filtering/">Filtering</a>
|
||||
<a href="../filtering">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../pagination/">Pagination</a>
|
||||
<a href="../pagination">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../versioning/">Versioning</a>
|
||||
<a href="../versioning">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../content-negotiation/">Content negotiation</a>
|
||||
<a href="../content-negotiation">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../metadata/">Metadata</a>
|
||||
<a href="../metadata">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../format-suffixes/">Format suffixes</a>
|
||||
<a href="../format-suffixes">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../reverse/">Returning URLs</a>
|
||||
<a href="../reverse">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../exceptions/">Exceptions</a>
|
||||
<a href="../exceptions">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../status-codes/">Status codes</a>
|
||||
<a href="../status-codes">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../testing/">Testing</a>
|
||||
<a href="../testing">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../settings/">Settings</a>
|
||||
<a href="../settings">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -236,55 +232,55 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../topics/documenting-your-api/">Documenting your API</a>
|
||||
<a href="../../topics/documenting-your-api">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/internationalization/">Internationalization</a>
|
||||
<a href="../../topics/internationalization">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
<a href="../../topics/ajax-csrf-cors">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browser-enhancements/">Browser enhancements</a>
|
||||
<a href="../../topics/browser-enhancements">Browser enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/browsable-api/">The Browsable API</a>
|
||||
<a href="../../topics/browsable-api">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
<a href="../../topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/third-party-resources/">Third Party Resources</a>
|
||||
<a href="../../topics/third-party-resources">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/contributing/">Contributing to REST framework</a>
|
||||
<a href="../../topics/contributing">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/project-management/">Project management</a>
|
||||
<a href="../../topics/project-management">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.0-announcement/">3.0 Announcement</a>
|
||||
<a href="../../topics/3.0-announcement">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/3.1-announcement/">3.1 Announcement</a>
|
||||
<a href="../../topics/3.1-announcement">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
<a href="../../topics/kickstarter-announcement">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../topics/release-notes/">Release Notes</a>
|
||||
<a href="../../topics/release-notes">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -425,7 +421,7 @@
|
|||
<p>HTTP/1.1 420 Enhance Your Calm</p>
|
||||
<p><a href="https://dev.twitter.com/docs/error-codes-responses">Twitter API rate limiting response</a></p>
|
||||
</blockquote>
|
||||
<p>Throttling is similar to <a href="../permissions/">permissions</a>, in that it determines if a request should be authorized. Throttles indicate a temporary state, and are used to control the rate of requests that clients can make to an API.</p>
|
||||
<p>Throttling is similar to <a href="../permissions">permissions</a>, in that it determines if a request should be authorized. Throttles indicate a temporary state, and are used to control the rate of requests that clients can make to an API.</p>
|
||||
<p>As with permissions, multiple throttles may be used. Your API might have a restrictive throttle for unauthenticated requests, and a less restrictive throttle for authenticated requests.</p>
|
||||
<p>Another scenario where you might want to use multiple throttles would be if you need to impose different constraints on different parts of the API, due to some services being particularly resource-intensive.</p>
|
||||
<p>Multiple throttles can also be used if you want to impose both burst throttling rates, and sustained throttling rates. For example, you might want to limit a user to a maximum of 60 requests per minute, and 1000 requests per day.</p>
|
||||
|
|
@ -561,6 +557,7 @@ class UploadView(APIView):
|
|||
def allow_request(self, request, view):
|
||||
return random.randint(1, 10) == 1
|
||||
</code></pre>
|
||||
|
||||
</div>
|
||||
<!--/span-->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Validators</title>
|
||||
<title>Validators - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/api-guide/validators/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../authentication/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../authentication">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../relations/">
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../relations">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
|
|
@ -81,40 +81,36 @@
|
|||
<ul class="nav navbar-nav">
|
||||
<li ><a href="/">Home</a></li>
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
<a href="../../tutorial/quickstart">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
<a href="../../tutorial/1-serialization">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
<a href="../../tutorial/2-requests-and-responses">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
<a href="../../tutorial/3-class-based-views">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
<a href="../../tutorial/4-authentication-and-permissions">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
<a href="../../tutorial/6-viewsets-and-routers">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
|
@ -125,107 +121,107 @@
|
|||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../requests/">Requests</a>
|
||||
<a href="../requests">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../responses/">Responses</a>
|
||||
<a href="../responses">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../views/">Views</a>
|
||||
<a href="../views">Views</a>
|
||||
| ||||