mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-16 19:41:06 +03:00
Deployed cf8a5b5f
with MkDocs version: 1.0.4
This commit is contained in:
parent
77a24aad40
commit
fd207b6c66
26
404.html
26
404.html
|
@ -5,22 +5,18 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Django REST framework</title>
|
||||
<link href="//img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link href="/img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="/." />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="Django, API, REST">
|
||||
<meta name="author" content="Tom Christie">
|
||||
|
||||
<!-- Le styles -->
|
||||
<link href="//css/prettify.css" rel="stylesheet">
|
||||
<link href="//css/bootstrap.css" rel="stylesheet">
|
||||
<link href="//css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="//css/default.css" rel="stylesheet">
|
||||
<link href="/css/prettify.css" rel="stylesheet">
|
||||
<link href="/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="/css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="/css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -406,7 +402,7 @@
|
|||
|
||||
|
||||
<div class="promo">
|
||||
<hr/>
|
||||
|
||||
<div id="sidebarInclude">
|
||||
</div>
|
||||
</ul>
|
||||
|
@ -419,7 +415,7 @@
|
|||
|
||||
<h1 id="404-page-not-found" style="text-align: center">404</h1>
|
||||
<p style="text-align: center"><strong>Page not found</strong></p>
|
||||
<p style="text-align: center">Try the <a href="https://www.django-rest-framework.org/">homepage</a>, or <a href="#searchModal" data-toggle="modal">search the documentation</a>.</p>
|
||||
<p style="text-align: center">Try the <a href="/">homepage</a>, or <a href="#mkdocs_search_modal" data-toggle="modal">search the documentation</a>.</p>
|
||||
|
||||
|
||||
|
||||
|
@ -439,10 +435,10 @@
|
|||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script async src="https://fund.django-rest-framework.org/sidebar_include.js"></script>
|
||||
<script src="//js/jquery-1.8.1-min.js"></script>
|
||||
<script src="//js/prettify-1.0.js"></script>
|
||||
<script src="//js/bootstrap-2.1.1-min.js"></script>
|
||||
<script src="//js/theme.js"></script>
|
||||
<script src="/js/jquery-1.8.1-min.js"></script>
|
||||
<script src="/js/prettify-1.0.js"></script>
|
||||
<script src="/js/bootstrap-2.1.1-min.js"></script>
|
||||
<script src="/js/theme.js"></script>
|
||||
|
||||
<script>var base_url = '/';</script>
|
||||
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -488,7 +484,7 @@
|
|||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#django-rest-auth">django-rest-auth</a>
|
||||
<a href="#django-rest-auth-dj-rest-auth">django-rest-auth / dj-rest-auth</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
|
@ -746,7 +742,7 @@ already exist. To change this and other behaviour, consult the
|
|||
<p>Consult your web server's documentation for information about configuring an authentication method, e.g.:</p>
|
||||
<ul>
|
||||
<li><a href="https://httpd.apache.org/docs/2.4/howto/auth.html">Apache Authentication How-To</a></li>
|
||||
<li><a href="https://www.nginx.com/resources/admin-guide/#restricting_access">NGINX (Restricting Access)</a></li>
|
||||
<li><a href="https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/">NGINX (Restricting Access)</a></li>
|
||||
</ul>
|
||||
<h1 id="custom-authentication"><a class="toclink" href="#custom-authentication">Custom authentication</a></h1>
|
||||
<p>To implement a custom authentication scheme, subclass <code>BaseAuthentication</code> and override the <code>.authenticate(self, request)</code> method. The method should return a two-tuple of <code>(user, auth)</code> if authentication succeeds, or <code>None</code> otherwise.</p>
|
||||
|
@ -818,8 +814,13 @@ REST_FRAMEWORK = {
|
|||
<p>HTTP Signature (currently a <a href="https://datatracker.ietf.org/doc/draft-cavage-http-signatures/">IETF draft</a>) provides a way to achieve origin authentication and message integrity for HTTP messages. Similar to <a href="https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html">Amazon's HTTP Signature scheme</a>, used by many of its services, it permits stateless, per-request authentication. <a href="https://github.com/etoccalino/">Elvio Toccalino</a> maintains the <a href="https://github.com/etoccalino/django-rest-framework-httpsignature">djangorestframework-httpsignature</a> (outdated) package which provides an easy to use HTTP Signature Authentication mechanism. You can use the updated fork version of <a href="https://github.com/etoccalino/django-rest-framework-httpsignature">djangorestframework-httpsignature</a>, which is <a href="https://github.com/ahknight/drf-httpsig">drf-httpsig</a>.</p>
|
||||
<h2 id="djoser"><a class="toclink" href="#djoser">Djoser</a></h2>
|
||||
<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"><a class="toclink" href="#django-rest-auth">django-rest-auth</a></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>
|
||||
<h2 id="django-rest-auth-dj-rest-auth"><a class="toclink" href="#django-rest-auth-dj-rest-auth">django-rest-auth / dj-rest-auth</a></h2>
|
||||
<p>This 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>
|
||||
<p>There are currently two forks of this project.</p>
|
||||
<ul>
|
||||
<li><a href="https://github.com/Tivix/django-rest-auth">Django-rest-auth</a> is the original project, <a href="https://github.com/Tivix/django-rest-auth/issues/568">but is not currently receiving updates</a>.</li>
|
||||
<li><a href="https://github.com/jazzband/dj-rest-auth">Dj-rest-auth</a> is a newer fork of the project.</li>
|
||||
</ul>
|
||||
<h2 id="django-rest-framework-social-oauth2"><a class="toclink" href="#django-rest-framework-social-oauth2">django-rest-framework-social-oauth2</a></h2>
|
||||
<p><a href="https://github.com/PhilipGarnero/django-rest-framework-social-oauth2">Django-rest-framework-social-oauth2</a> library provides an easy way to integrate social plugins (facebook, twitter, google, etc.) to your authentication system and an easy oauth2 setup. With this library, you will be able to authenticate users based on external tokens (e.g. facebook access token), convert these tokens to "in-house" oauth2 tokens and use and generate oauth2 tokens to authenticate your users.</p>
|
||||
<h2 id="django-rest-knox"><a class="toclink" href="#django-rest-knox">django-rest-knox</a></h2>
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -1041,11 +1037,10 @@ class UserSerializer(serializers.ModelSerializer):
|
|||
<p>If you want to create a custom field, you'll need to subclass <code>Field</code> and then override either one or both of the <code>.to_representation()</code> and <code>.to_internal_value()</code> methods. These two methods are used to convert between the initial datatype, and a primitive, serializable datatype. Primitive datatypes will typically be any of a number, string, boolean, <code>date</code>/<code>time</code>/<code>datetime</code> or <code>None</code>. They may also be any list or dictionary like object that only contains other primitive objects. Other types might be supported, depending on the renderer that you are using.</p>
|
||||
<p>The <code>.to_representation()</code> method is called to convert the initial datatype into a primitive, serializable datatype.</p>
|
||||
<p>The <code>to_internal_value()</code> method is called to restore a primitive datatype into its internal python representation. This method should raise a <code>serializers.ValidationError</code> if the data is invalid.</p>
|
||||
<p>Note that the <code>WritableField</code> class that was present in version 2.x no longer exists. You should subclass <code>Field</code> and override <code>to_internal_value()</code> if the field supports data input.</p>
|
||||
<h2 id="examples"><a class="toclink" href="#examples">Examples</a></h2>
|
||||
<h3 id="a-basic-custom-field"><a class="toclink" href="#a-basic-custom-field">A Basic Custom Field</a></h3>
|
||||
<p>Let's look at an example of serializing a class that represents an RGB color value:</p>
|
||||
<pre><code>class Color(object):
|
||||
<pre><code>class Color:
|
||||
"""
|
||||
A color represented in the RGB colorspace.
|
||||
"""
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -674,12 +670,15 @@ class UserListView(generics.ListAPIView):
|
|||
<p>You can also perform a related lookup on a ForeignKey or ManyToManyField with the lookup API double-underscore notation:</p>
|
||||
<pre><code>search_fields = ['username', 'email', 'profile__profession']
|
||||
</code></pre>
|
||||
<p>For <a href="https://docs.djangoproject.com/en/3.0/ref/contrib/postgres/fields/#jsonfield">JSONField</a> and <a href="https://docs.djangoproject.com/en/3.0/ref/contrib/postgres/fields/#hstorefield">HStoreField</a> fields you can filter based on nested values within the data structure using the same double-underscore notation:</p>
|
||||
<pre><code>search_fields = ['data__breed', 'data__owner__other_pets__0__name']
|
||||
</code></pre>
|
||||
<p>By default, searches will use case-insensitive partial matches. The search parameter may contain multiple search terms, which should be whitespace and/or comma separated. If multiple search terms are used then objects will be returned in the list only if all the provided terms are matched.</p>
|
||||
<p>The search behavior may be restricted by prepending various characters to the <code>search_fields</code>.</p>
|
||||
<ul>
|
||||
<li>'^' Starts-with search.</li>
|
||||
<li>'=' Exact matches.</li>
|
||||
<li>'@' Full-text search. (Currently only supported Django's MySQL backend.)</li>
|
||||
<li>'@' Full-text search. (Currently only supported Django's <a href="https://docs.djangoproject.com/en/dev/ref/contrib/postgres/search/">PostgreSQL backend</a>.)</li>
|
||||
<li>'$' Regex search.</li>
|
||||
</ul>
|
||||
<p>For example:</p>
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -678,7 +674,6 @@ class UserList(generics.ListCreateAPIView):
|
|||
raise ValidationError('You have already signed up')
|
||||
serializer.save(user=self.request.user)
|
||||
</code></pre>
|
||||
<p><strong>Note</strong>: These methods replace the old-style version 2.x <code>pre_save</code>, <code>post_save</code>, <code>pre_delete</code> and <code>post_delete</code> methods, which are no longer available.</p>
|
||||
<p><strong>Other methods</strong>:</p>
|
||||
<p>You won't typically need to override the following methods, although you might need to call into them if you're writing custom views using <code>GenericAPIView</code>.</p>
|
||||
<ul>
|
||||
|
@ -755,7 +750,7 @@ class UserList(generics.ListCreateAPIView):
|
|||
<p>Often you'll want to use the existing generic views, but use some slightly customized behavior. If you find yourself reusing some bit of customized behavior in multiple places, you might want to refactor the behavior into a common class that you can then just apply to any view or viewset as needed.</p>
|
||||
<h2 id="creating-custom-mixins"><a class="toclink" href="#creating-custom-mixins">Creating custom mixins</a></h2>
|
||||
<p>For example, if you need to lookup objects based on multiple fields in the URL conf, you could create a mixin class like the following:</p>
|
||||
<pre><code>class MultipleFieldLookupMixin(object):
|
||||
<pre><code>class MultipleFieldLookupMixin:
|
||||
"""
|
||||
Apply this mixin to any view or viewset to get multiple field filtering
|
||||
based on a `lookup_fields` attribute, instead of the default single field filtering.
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -515,7 +511,7 @@ Content-Type: application/json
|
|||
<p>If you have specific requirements for creating schema endpoints that are accessed with regular <code>GET</code> requests, you might consider re-using the metadata API for doing so.</p>
|
||||
<p>For example, the following additional route could be used on a viewset to provide a linkable schema endpoint.</p>
|
||||
<pre><code>@action(methods=['GET'], detail=False)
|
||||
def schema(self, request):
|
||||
def api_schema(self, request):
|
||||
meta = self.metadata_class()
|
||||
data = meta.determine_metadata(request, self)
|
||||
return Response(data)
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -684,7 +680,7 @@ else:
|
|||
<hr />
|
||||
<p><strong>Note</strong>: The instance-level <code>has_object_permission</code> method will only be called if the view-level <code>has_permission</code> checks have already passed. Also note that in order for the instance-level checks to run, the view code should explicitly call <code>.check_object_permissions(request, obj)</code>. If you are using the generic views then this will be handled for you by default. (Function-based views will need to check object permissions explicitly, raising <code>PermissionDenied</code> on failure.)</p>
|
||||
<hr />
|
||||
<p>Custom permissions will raise a <code>PermissionDenied</code> exception if the test fails. To change the error message associated with the exception, implement a <code>message</code> attribute directly on your custom permission. Otherwise the <code>default_detail</code> attribute from <code>PermissionDenied</code> will be used.</p>
|
||||
<p>Custom permissions will raise a <code>PermissionDenied</code> exception if the test fails. To change the error message associated with the exception, implement a <code>message</code> attribute directly on your custom permission. Otherwise the <code>default_detail</code> attribute from <code>PermissionDenied</code> will be used. Similarly, to change the code identifier associated with the exception, implement a <code>code</code> attribute directly on your custom permission - otherwise the <code>default_code</code> attribute from <code>PermissionDenied</code> will be used.</p>
|
||||
<pre><code>from rest_framework import permissions
|
||||
|
||||
class CustomerAccessPermission(permissions.BasePermission):
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -748,7 +744,7 @@ def simple_html_view(request):
|
|||
<p>By default this will include the following keys: <code>view</code>, <code>request</code>, <code>response</code>, <code>args</code>, <code>kwargs</code>.</p>
|
||||
<h2 id="example"><a class="toclink" href="#example">Example</a></h2>
|
||||
<p>The following is an example plaintext renderer that will return a response with the <code>data</code> parameter as the content of the response.</p>
|
||||
<pre><code>from django.utils.encoding import smart_unicode
|
||||
<pre><code>from django.utils.encoding import smart_text
|
||||
from rest_framework import renderers
|
||||
|
||||
|
||||
|
@ -757,7 +753,7 @@ class PlainTextRenderer(renderers.BaseRenderer):
|
|||
format = 'txt'
|
||||
|
||||
def render(self, data, media_type=None, renderer_context=None):
|
||||
return data.encode(self.charset)
|
||||
return smart_text(data, encoding=self.charset)
|
||||
</code></pre>
|
||||
<h2 id="setting-the-character-set"><a class="toclink" href="#setting-the-character-set">Setting the character set</a></h2>
|
||||
<p>By default renderer classes are assumed to be using the <code>UTF-8</code> encoding. To use a different encoding, set the <code>charset</code> attribute on the renderer.</p>
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -449,14 +445,16 @@ can interact with your API.</p>
|
|||
<p>Django REST Framework provides support for automatic generation of
|
||||
<a href="https://github.com/OAI/OpenAPI-Specification">OpenAPI</a> schemas.</p>
|
||||
<h2 id="generating-an-openapi-schema"><a class="toclink" href="#generating-an-openapi-schema">Generating an OpenAPI Schema</a></h2>
|
||||
<h3 id="install-pyyaml"><a class="toclink" href="#install-pyyaml">Install <code>pyyaml</code></a></h3>
|
||||
<p>You'll need to install <code>pyyaml</code>, so that you can render your generated schema
|
||||
into the commonly used YAML-based OpenAPI format.</p>
|
||||
<pre><code>pip install pyyaml
|
||||
<h3 id="install-dependencies"><a class="toclink" href="#install-dependencies">Install dependencies</a></h3>
|
||||
<pre><code>pip install pyyaml uritemplate
|
||||
</code></pre>
|
||||
<ul>
|
||||
<li><code>pyyaml</code> is used to generate schema into YAML-based OpenAPI format.</li>
|
||||
<li><code>uritemplate</code> is used internally to get parameters in path.</li>
|
||||
</ul>
|
||||
<h3 id="generating-a-static-schema-with-the-generateschema-management-command"><a class="toclink" href="#generating-a-static-schema-with-the-generateschema-management-command">Generating a static schema with the <code>generateschema</code> management command</a></h3>
|
||||
<p>If your schema is static, you can use the <code>generateschema</code> management command:</p>
|
||||
<pre><code class="bash">./manage.py generateschema > openapi-schema.yml
|
||||
<pre><code class="bash">./manage.py generateschema --file openapi-schema.yml
|
||||
</code></pre>
|
||||
|
||||
<p>Once you've generated a schema in this way you can annotate it with any
|
||||
|
@ -542,7 +540,7 @@ schema_view = get_schema_view(
|
|||
<p>You may customize schema generation at the level of the schema as a whole, or
|
||||
on a per-view basis.</p>
|
||||
<h3 id="schema-level-customization"><a class="toclink" href="#schema-level-customization">Schema Level Customization</a></h3>
|
||||
<p>In order to customize the top-level schema sublass
|
||||
<p>In order to customize the top-level schema subclass
|
||||
<code>rest_framework.schemas.openapi.SchemaGenerator</code> and provide it as an argument
|
||||
to the <code>generateschema</code> command or <code>get_schema_view()</code> helper function.</p>
|
||||
<h4 id="schemagenerator"><a class="toclink" href="#schemagenerator">SchemaGenerator</a></h4>
|
||||
|
@ -616,6 +614,189 @@ provide richer path field descriptions. (The key hooks here are the relevant
|
|||
</code></pre>
|
||||
<p>If you wish to provide a base <code>AutoSchema</code> subclass to be used throughout your
|
||||
project you may adjust <code>settings.DEFAULT_SCHEMA_CLASS</code> appropriately.</p>
|
||||
<h3 id="grouping-operations-with-tags"><a class="toclink" href="#grouping-operations-with-tags">Grouping Operations With Tags</a></h3>
|
||||
<p>Tags can be used to group logical operations. Each tag name in the list MUST be unique. </p>
|
||||
<hr />
|
||||
<h4 id="django-rest-framework-generates-tags-automatically-with-the-following-logic"><a class="toclink" href="#django-rest-framework-generates-tags-automatically-with-the-following-logic">Django REST Framework generates tags automatically with the following logic:</a></h4>
|
||||
<p>Tag name will be first element from the path. Also, any <code>_</code> in path name will be replaced by a <code>-</code>.
|
||||
Consider below examples.</p>
|
||||
<p>Example 1: Consider a user management system. The following table will illustrate the tag generation logic.
|
||||
Here first element from the paths is: <code>users</code>. Hence tag wil be <code>users</code></p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Http Method</th>
|
||||
<th>Path</th>
|
||||
<th>Tags</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>PUT, PATCH, GET(Retrieve), DELETE</td>
|
||||
<td>/users/{id}/</td>
|
||||
<td>['users']</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>POST, GET(List)</td>
|
||||
<td>/users/</td>
|
||||
<td>['users']</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Example 2: Consider a restaurant management system. The System has restaurants. Each restaurant has branches.
|
||||
Consider REST APIs to deal with a branch of a particular restaurant.
|
||||
Here first element from the paths is: <code>restaurants</code>. Hence tag wil be <code>restaurants</code>.</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Http Method</th>
|
||||
<th>Path</th>
|
||||
<th>Tags</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>PUT, PATCH, GET(Retrieve), DELETE:</td>
|
||||
<td>/restaurants/{restaurant_id}/branches/{branch_id}</td>
|
||||
<td>['restaurants']</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>POST, GET(List):</td>
|
||||
<td>/restaurants/{restaurant_id}/branches/</td>
|
||||
<td>['restaurants']</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Example 3: Consider Order items for an e commerce company.</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Http Method</th>
|
||||
<th>Path</th>
|
||||
<th>Tags</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>PUT, PATCH, GET(Retrieve), DELETE</td>
|
||||
<td>/order_items/{id}/</td>
|
||||
<td>['order-items']</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>POST, GET(List)</td>
|
||||
<td>/order_items/</td>
|
||||
<td>['order-items']</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<hr />
|
||||
<h4 id="overriding-auto-generated-tags"><a class="toclink" href="#overriding-auto-generated-tags">Overriding auto generated tags:</a></h4>
|
||||
<p>You can override auto-generated tags by passing <code>tags</code> argument to the constructor of <code>AutoSchema</code>. <code>tags</code> argument must be a list or tuple of string.</p>
|
||||
<pre><code class="python">from rest_framework.schemas.openapi import AutoSchema
|
||||
from rest_framework.views import APIView
|
||||
|
||||
class MyView(APIView):
|
||||
schema = AutoSchema(tags=['tag1', 'tag2'])
|
||||
...
|
||||
</code></pre>
|
||||
|
||||
<p>If you need more customization, you can override the <code>get_tags</code> method of <code>AutoSchema</code> class. Consider the following example:</p>
|
||||
<pre><code class="python">from rest_framework.schemas.openapi import AutoSchema
|
||||
from rest_framework.views import APIView
|
||||
|
||||
class MySchema(AutoSchema):
|
||||
...
|
||||
def get_tags(self, path, method):
|
||||
if method == 'POST':
|
||||
tags = ['tag1', 'tag2']
|
||||
elif method == 'GET':
|
||||
tags = ['tag2', 'tag3']
|
||||
elif path == '/example/path/':
|
||||
tags = ['tag3', 'tag4']
|
||||
else:
|
||||
tags = ['tag5', 'tag6', 'tag7']
|
||||
|
||||
return tags
|
||||
|
||||
class MyView(APIView):
|
||||
schema = MySchema()
|
||||
...
|
||||
</code></pre>
|
||||
|
||||
<h3 id="operationid"><a class="toclink" href="#operationid">OperationId</a></h3>
|
||||
<p>The schema generator generates an <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#fixed-fields-17">operationid</a> for each operation. This <code>operationId</code> is deduced from the model name, serializer name or view name. The operationId may looks like "listItems", "retrieveItem", "updateItem", etc..
|
||||
The <code>operationId</code> is camelCase by convention.</p>
|
||||
<p>If you have several views with the same model, the generator may generate duplicate operationId.
|
||||
In order to work around this, you can override the second part of the operationId: operation name.</p>
|
||||
<pre><code class="python">from rest_framework.schemas.openapi import AutoSchema
|
||||
|
||||
class ExampleView(APIView):
|
||||
"""APIView subclass with custom schema introspection."""
|
||||
schema = AutoSchema(operation_id_base="Custom")
|
||||
</code></pre>
|
||||
|
||||
<p>The previous example will generate the following operationId: "listCustoms", "retrieveCustom", "updateCustom", "partialUpdateCustom", "destroyCustom".
|
||||
You need to provide the singular form of he operation name. For the list operation, a "s" will be appended at the end of the operation.</p>
|
||||
<p>If you need more configuration over the <code>operationId</code> field, you can override the <code>get_operation_id_base</code> and <code>get_operation_id</code> methods from the <code>AutoSchema</code> class:</p>
|
||||
<pre><code class="python">class CustomSchema(AutoSchema):
|
||||
def get_operation_id_base(self, path, method, action):
|
||||
pass
|
||||
|
||||
def get_operation_id(self, path, method):
|
||||
pass
|
||||
|
||||
class MyView(APIView):
|
||||
schema = AutoSchema(component_name="Ulysses")
|
||||
</code></pre>
|
||||
|
||||
<h3 id="components"><a class="toclink" href="#components">Components</a></h3>
|
||||
<p>Since DRF 3.12, Schema uses the <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#componentsObject">OpenAPI Components</a>. This method defines components in the schema and <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#referenceObject">references them</a> inside request and response objects. By default, the component's name is deduced from the Serializer's name.</p>
|
||||
<p>Using OpenAPI's components provides the following advantages:</p>
|
||||
<ul>
|
||||
<li>The schema is more readable and lightweight.</li>
|
||||
<li>If you use the schema to generate an SDK (using <a href="https://github.com/OpenAPITools/openapi-generator">openapi-generator</a> or <a href="https://github.com/swagger-api/swagger-codegen">swagger-codegen</a>). The generator can name your SDK's models.</li>
|
||||
</ul>
|
||||
<h3 id="handling-components-schema-errors"><a class="toclink" href="#handling-components-schema-errors">Handling component's schema errors</a></h3>
|
||||
<p>You may get the following error while generating the schema:</p>
|
||||
<pre><code>"Serializer" is an invalid class name for schema generation.
|
||||
Serializer's class name should be unique and explicit. e.g. "ItemSerializer".
|
||||
</code></pre>
|
||||
|
||||
<p>This error occurs when the Serializer name is "Serializer". You should choose a component's name unique across your schema and different than "Serializer".</p>
|
||||
<p>You may also get the following warning:</p>
|
||||
<pre><code>Schema component "ComponentName" has been overriden with a different value.
|
||||
</code></pre>
|
||||
|
||||
<p>This warning occurs when different components have the same name in one schema. Your component name should be unique across your project. This is likely an error that may lead to an invalid schema.</p>
|
||||
<p>You have two ways to solve the previous issues:</p>
|
||||
<ul>
|
||||
<li>You can rename your serializer with a unique name and another name than "Serializer".</li>
|
||||
<li>You can set the <code>component_name</code> kwarg parameter of the AutoSchema constructor (see below).</li>
|
||||
<li>You can override the <code>get_component_name</code> method of the AutoSchema class (see below).</li>
|
||||
</ul>
|
||||
<h4 id="set-a-custom-components-name-for-your-view"><a class="toclink" href="#set-a-custom-components-name-for-your-view">Set a custom component's name for your view</a></h4>
|
||||
<p>To override the component's name in your view, you can use the <code>component_name</code> parameter of the AutoSchema constructor:</p>
|
||||
<pre><code class="python">from rest_framework.schemas.openapi import AutoSchema
|
||||
|
||||
class MyView(APIView):
|
||||
schema = AutoSchema(component_name="Ulysses")
|
||||
</code></pre>
|
||||
|
||||
<h4 id="override-the-default-implementation"><a class="toclink" href="#override-the-default-implementation">Override the default implementation</a></h4>
|
||||
<p>If you want to have more control and customization about how the schema's components are generated, you can override the <code>get_component_name</code> and <code>get_components</code> method from the AutoSchema class.</p>
|
||||
<pre><code class="python">from rest_framework.schemas.openapi import AutoSchema
|
||||
|
||||
class CustomSchema(AutoSchema):
|
||||
def get_components(self, path, method):
|
||||
# Implement your custom implementation
|
||||
|
||||
def get_component_name(self, serializer):
|
||||
# Implement your custom implementation
|
||||
|
||||
class CustomView(APIView):
|
||||
"""APIView subclass with custom schema introspection."""
|
||||
schema = CustomSchema()
|
||||
</code></pre>
|
||||
|
||||
|
||||
</div> <!--/span-->
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -655,7 +651,7 @@ will take some serious design work.</p>
|
|||
<p>Let's start by creating a simple object we can use for example purposes:</p>
|
||||
<pre><code>from datetime import datetime
|
||||
|
||||
class Comment(object):
|
||||
class Comment:
|
||||
def __init__(self, email, content, created=None):
|
||||
self.email = email
|
||||
self.content = content
|
||||
|
@ -830,10 +826,12 @@ class GameRecord(serializers.Serializer):
|
|||
|
||||
class Meta:
|
||||
# Each room only has one event per day.
|
||||
validators = UniqueTogetherValidator(
|
||||
queryset=Event.objects.all(),
|
||||
fields=['room_number', 'date']
|
||||
)
|
||||
validators = [
|
||||
UniqueTogetherValidator(
|
||||
queryset=Event.objects.all(),
|
||||
fields=['room_number', 'date']
|
||||
)
|
||||
]
|
||||
</code></pre>
|
||||
<p>For more information see the <a href="../validators/">validators documentation</a>.</p>
|
||||
<h2 id="accessing-the-initial-data-and-instance"><a class="toclink" href="#accessing-the-initial-data-and-instance">Accessing the initial data and instance</a></h2>
|
||||
|
@ -906,7 +904,7 @@ serializer.errors
|
|||
<pre><code> def update(self, instance, validated_data):
|
||||
profile_data = validated_data.pop('profile')
|
||||
# Unless the application properly enforces that this field is
|
||||
# always set, the follow could raise a `DoesNotExist`, which
|
||||
# always set, the following could raise a `DoesNotExist`, which
|
||||
# would need to be handled.
|
||||
profile = instance.profile
|
||||
|
||||
|
@ -949,8 +947,8 @@ serializer.errors
|
|||
<pre><code>def create(self, validated_data):
|
||||
return User.objects.create(
|
||||
username=validated_data['username'],
|
||||
email=validated_data['email']
|
||||
is_premium_member=validated_data['profile']['is_premium_member']
|
||||
email=validated_data['email'],
|
||||
is_premium_member=validated_data['profile']['is_premium_member'],
|
||||
has_support_contract=validated_data['profile']['has_support_contract']
|
||||
)
|
||||
</code></pre>
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -703,7 +699,7 @@ assert response.status_code == 200
|
|||
<p>If you're using <code>RequestsClient</code> you'll want to ensure that test setup, and results assertions are performed as regular API calls, rather than interacting with the database models directly. For example, rather than checking that <code>Customer.objects.count() == 3</code> you would list the customers endpoint, and ensure that it contains three records.</p>
|
||||
<h2 id="headers-authentication"><a class="toclink" href="#headers-authentication">Headers & Authentication</a></h2>
|
||||
<p>Custom headers and authentication credentials can be provided in the same way
|
||||
as <a href="http://docs.python-requests.org/en/master/user/advanced/#session-objects">when using a standard <code>requests.Session</code> instance</a>.</p>
|
||||
as <a href="https://requests.readthedocs.io/en/master/user/advanced/#session-objects">when using a standard <code>requests.Session</code> instance</a>.</p>
|
||||
<pre><code>from requests.auth import HTTPBasicAuth
|
||||
|
||||
client.auth = HTTPBasicAuth('user', 'pass')
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -712,7 +708,7 @@ to your <code>Serializer</code> subclass. This is documented in the
|
|||
<a href="https://www.django-rest-framework.org/api-guide/serializers/#field-level-validation">Serializer docs</a></p>
|
||||
<h2 id="class-based"><a class="toclink" href="#class-based">Class-based</a></h2>
|
||||
<p>To write a class-based validator, use the <code>__call__</code> method. Class-based validators are useful as they allow you to parameterize and reuse behavior.</p>
|
||||
<pre><code>class MultipleOf(object):
|
||||
<pre><code>class MultipleOf:
|
||||
def __init__(self, base):
|
||||
self.base = base
|
||||
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -485,7 +481,7 @@
|
|||
<h1 id="viewsets"><a class="toclink" href="#viewsets">ViewSets</a></h1>
|
||||
<blockquote>
|
||||
<p>After routing has determined which controller to use for a request, your controller is responsible for making sense of the request and producing the appropriate output.</p>
|
||||
<p>— <a href="https://guides.rubyonrails.org/routing.html">Ruby on Rails Documentation</a></p>
|
||||
<p>— <a href="https://guides.rubyonrails.org/action_controller_overview.html">Ruby on Rails Documentation</a></p>
|
||||
</blockquote>
|
||||
<p>Django REST framework allows you to combine the logic for a set of related views in a single class, called a <code>ViewSet</code>. In other frameworks you may also find conceptually similar implementations named something like 'Resources' or 'Controllers'.</p>
|
||||
<p>A <code>ViewSet</code> class is simply <strong>a type of class-based View, that does not provide any method handlers</strong> such as <code>.get()</code> or <code>.post()</code>, and instead provides actions such as <code>.list()</code> and <code>.create()</code>.</p>
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -421,6 +417,10 @@
|
|||
<a href="#upgrading">Upgrading</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#311x-series">3.11.x series</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#310x-series">3.10.x series</a>
|
||||
</li>
|
||||
|
@ -508,8 +508,27 @@
|
|||
<pre><code>pip show djangorestframework
|
||||
</code></pre>
|
||||
<hr />
|
||||
<h2 id="311x-series"><a class="toclink" href="#311x-series">3.11.x series</a></h2>
|
||||
<h3 id="3110"><a class="toclink" href="#3110">3.11.0</a></h3>
|
||||
<p><strong>Date</strong>: 12th December 2019</p>
|
||||
<ul>
|
||||
<li>Drop <code>.set_context</code> API <a href="../3.11-announcement#validator-default-context">in favour of a <code>requires_context</code> marker</a>.</li>
|
||||
<li>Changed default widget for TextField with choices to select box. <a href="https://github.com/encode/django-rest-framework/issues/6892">#6892</a></li>
|
||||
<li>Supported nested writes on non-relational fields, such as JSONField. <a href="https://github.com/encode/django-rest-framework/issues/6916">#6916</a></li>
|
||||
<li>Include request/response media types in OpenAPI schemas, based on configured parsers/renderers. <a href="https://github.com/encode/django-rest-framework/issues/6865">#6865</a></li>
|
||||
<li>Include operation descriptions in OpenAPI schemas, based on the docstring on the view. <a href="https://github.com/encode/django-rest-framework/issues/6898">#6898</a></li>
|
||||
<li>Fix representation of serializers with all optional fields in OpenAPI schemas. <a href="https://github.com/encode/django-rest-framework/issues/6941">#6941</a>, <a href="https://github.com/encode/django-rest-framework/issues/6944">#6944</a></li>
|
||||
<li>Fix representation of <code>serializers.HStoreField</code> in OpenAPI schemas. <a href="https://github.com/encode/django-rest-framework/issues/6914">#6914</a></li>
|
||||
<li>Fix OpenAPI generation when title or version is not provided. <a href="https://github.com/encode/django-rest-framework/issues/6912">#6912</a></li>
|
||||
<li>Use <code>int64</code> representation for large integers in OpenAPI schemas. <a href="https://github.com/encode/django-rest-framework/issues/7018">#7018</a></li>
|
||||
<li>Improved error messages if no <code>.to_representation</code> implementation is provided on a field subclass. <a href="https://github.com/encode/django-rest-framework/issues/6996">#6996</a></li>
|
||||
<li>Fix for serializer classes that use multiple inheritance. <a href="https://github.com/encode/django-rest-framework/issues/6980">#6980</a></li>
|
||||
<li>Fix for reversing Hyperlinked URL fields with percent encoded components in the path. <a href="https://github.com/encode/django-rest-framework/issues/7059">#7059</a></li>
|
||||
<li>Update bootstrap to 3.4.1. <a href="https://github.com/encode/django-rest-framework/issues/6923">#6923</a></li>
|
||||
</ul>
|
||||
<h2 id="310x-series"><a class="toclink" href="#310x-series">3.10.x series</a></h2>
|
||||
<h3 id="3103"><a class="toclink" href="#3103">3.10.3</a></h3>
|
||||
<p><strong>Date</strong>: 4th September 2019</p>
|
||||
<ul>
|
||||
<li>Include API version in OpenAPI schema generation, defaulting to empty string.</li>
|
||||
<li>Add pagination properties to OpenAPI response schemas.</li>
|
||||
|
@ -520,12 +539,7 @@
|
|||
<li>Use consistent <code>lowerInitialCamelCase</code> style in OpenAPI operation IDs.</li>
|
||||
<li>Fix <code>minLength</code>/<code>maxLength</code>/<code>minItems</code>/<code>maxItems</code> properties in OpenAPI schemas.</li>
|
||||
<li>Only call <code>FileField.url</code> once in serialization, for improved performance.</li>
|
||||
<li>
|
||||
<p>Fix an edge case where throttling calcualtions could error after a configuration change.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>TODO</p>
|
||||
</li>
|
||||
<li>Fix an edge case where throttling calculations could error after a configuration change.</li>
|
||||
</ul>
|
||||
<h3 id="3102"><a class="toclink" href="#3102">3.10.2</a></h3>
|
||||
<p><strong>Date</strong>: 29th July 2019</p>
|
||||
|
@ -617,7 +631,7 @@ Be sure to upgrade to Python 3 before upgrading to Django REST Framework 3.10.</
|
|||
<li>Add testing of Python 3.7 support <a href="https://github.com/encode/django-rest-framework/issues/6141">#6141</a></li>
|
||||
<li>Test using Django 2.1 final release. <a href="https://github.com/encode/django-rest-framework/issues/6109">#6109</a></li>
|
||||
<li>Added djangorestframework-datatables to third-party packages <a href="https://github.com/encode/django-rest-framework/issues/5931">#5931</a></li>
|
||||
<li>Change ISO 8601 date format to exclude year/month <a href="https://github.com/encode/django-rest-framework/issues/5936">#5936</a></li>
|
||||
<li>Change ISO 8601 date format to exclude year/month-only options <a href="https://github.com/encode/django-rest-framework/issues/5936">#5936</a></li>
|
||||
<li>Update all pypi.python.org URLs to pypi.org <a href="https://github.com/encode/django-rest-framework/issues/5942">#5942</a></li>
|
||||
<li>Ensure that html forms (multipart form data) respect optional fields <a href="https://github.com/encode/django-rest-framework/issues/5927">#5927</a></li>
|
||||
<li>Allow hashing of ErrorDetail. <a href="https://github.com/encode/django-rest-framework/issues/5932">#5932</a></li>
|
||||
|
@ -1645,6 +1659,8 @@ Previously may have been stored internally as <code>None</code>.</p>
|
|||
<!-- 3.9.3 -->
|
||||
|
||||
<!-- 3.10.0 -->
|
||||
|
||||
<!-- 3.11.0 -->
|
||||
|
||||
|
||||
</div> <!--/span-->
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -597,6 +593,7 @@ You probably want to also tag the version now:
|
|||
<h3 id="views"><a class="toclink" href="#views">Views</a></h3>
|
||||
<ul>
|
||||
<li><a href="https://github.com/MattBroach/DjangoRestMultipleModels">django-rest-multiple-models</a> - Provides a generic view (and mixin) for sending multiple serialized models and/or querysets via a single API request.</li>
|
||||
<li><a href="https://github.com/rsinger86/drf-typed-views">drf-typed-views</a> - Use Python type annotations to validate/deserialize request parameters. Inspired by API Star, Hug and FastAPI.</li>
|
||||
</ul>
|
||||
<h3 id="routers"><a class="toclink" href="#routers">Routers</a></h3>
|
||||
<ul>
|
||||
|
@ -644,7 +641,9 @@ You probably want to also tag the version now:
|
|||
<li><a href="https://github.com/jozo/django-rest-framework-condition">django-rest-framework-condition</a> - Decorators for managing HTTP cache headers for Django REST framework (ETag and Last-modified).</li>
|
||||
<li><a href="https://github.com/shosca/django-rest-witchcraft">django-rest-witchcraft</a> - Provides DRF integration with SQLAlchemy with SQLAlchemy model serializers/viewsets and a bunch of other goodies</li>
|
||||
<li><a href="https://github.com/corteva/djangorestframework-mvt">djangorestframework-mvt</a> - An extension for creating views that serve Postgres data as Map Box Vector Tiles.</li>
|
||||
<li><a href="https://github.com/fvlima/drf-viewset-profiler">drf-viewset-profiler</a> - Lib to profile all methods from a viewset line by line.</li>
|
||||
<li><a href="https://github.com/cloudcode-hungary/django-rest-framework-features/">djangorestframework-features</a> - Advanced schema generation and more based on named features.</li>
|
||||
<li><a href="https://github.com/barseghyanartur/django-elasticsearch-dsl-drf">django-elasticsearch-dsl-drf</a> - Integrate Elasticsearch DSL with Django REST framework. Package provides views, serializers, filter backends, pagination and other handy add-ons.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -450,8 +446,8 @@
|
|||
<a class="book-cover" href="https://www.twoscoopspress.com/products/two-scoops-of-django-1-11">
|
||||
<img src="../../img/books/tsd-cover.png"/>
|
||||
</a>
|
||||
<a class="book-cover" href="https://wsvincent.com/books/">
|
||||
<img src="../../img/books/rad-cover.png"/>
|
||||
<a class="book-cover" href="https://djangoforapis.com">
|
||||
<img src="../../img/books/dfa-cover.jpg"/>
|
||||
</a>
|
||||
<a class="book-cover" href="https://books.agiliq.com/projects/django-api-polls-tutorial/en/latest/">
|
||||
<img src="../../img/books/bda-cover.png"/>
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -6,7 +6,7 @@ pre {
|
|||
|
||||
.dropdown .dropdown-menu {
|
||||
display: none;
|
||||
overflow-y: scroll;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.dropdown.open .dropdown-menu {
|
||||
|
@ -74,6 +74,12 @@ pre {
|
|||
white-space: pre;
|
||||
}
|
||||
|
||||
code, pre {
|
||||
font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,sans-serif;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
|
||||
/* Preserve the spacing of the navbar across different screen sizes. */
|
||||
.navbar-inner {
|
||||
/*padding: 5px 0;*/
|
||||
|
@ -432,3 +438,4 @@ ul.sponsor {
|
|||
margin: 0 !important;
|
||||
display: inline-block !important;
|
||||
}
|
||||
|
||||
|
|
BIN
img/books/dfa-cover.jpg
Normal file
BIN
img/books/dfa-cover.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
Binary file not shown.
Before Width: | Height: | Size: 14 KiB |
BIN
img/premium/bitio-readme.png
Normal file
BIN
img/premium/bitio-readme.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
46
index.html
46
index.html
|
@ -5,22 +5,18 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Home - Django REST framework</title>
|
||||
<link href="./img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link href="img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="https://www.django-rest-framework.org/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="Django, API, REST, Home">
|
||||
<meta name="author" content="Tom Christie">
|
||||
|
||||
<!-- Le styles -->
|
||||
<link href="./css/prettify.css" rel="stylesheet">
|
||||
<link href="./css/bootstrap.css" rel="stylesheet">
|
||||
<link href="./css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="./css/default.css" rel="stylesheet">
|
||||
<link href="css/prettify.css" rel="stylesheet">
|
||||
<link href="css/bootstrap.css" rel="stylesheet">
|
||||
<link href="css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -518,15 +514,9 @@
|
|||
clip: rect(0,0,0,0);
|
||||
border: 0;">Django REST Framework</h1>
|
||||
|
||||
<a><img alt="Black Lives Matter" src="img/blacklivesmatter.png" width="600px" style="display: block; margin: 0 auto 0 auto"></a>
|
||||
<center><h4>BLACK LIVES MATTER</h4></center>
|
||||
<img alt="Django REST Framework" title="Logo by Jake 'Sid' Smith" src="img/logo.png" width="600px" style="display: block; margin: 0 auto 0 auto">
|
||||
</p>
|
||||
|
||||
<hr />
|
||||
<p><center>
|
||||
<a href="https://blacklivesmatter.com/">Black Lives Matter</a> · <a href="https://eji.org/">The Equal Justice Initiative</a> · <a href="http://www.wetheprotesters.org/">We The Protestors</a>
|
||||
</center></p>
|
||||
<hr />
|
||||
<p>Django REST framework is a powerful and flexible toolkit for building Web APIs.</p>
|
||||
<p>Some reasons you might want to use REST framework:</p>
|
||||
<ul>
|
||||
|
@ -548,27 +538,25 @@ continued development by <strong><a href="community/funding/">signing up for a p
|
|||
<li><a href="https://getstream.io/try-the-api/?utm_source=drf&utm_medium=banner&utm_campaign=drf" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/stream-130.png)">Stream</a></li>
|
||||
<li><a href="https://software.esg-usa.com" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/esg-new-logo.png)">ESG</a></li>
|
||||
<li><a href="https://rollbar.com" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/rollbar2.png)">Rollbar</a></li>
|
||||
<li><a href="https://cadre.com" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/cadre.png)">Cadre</a></li>
|
||||
<li><a href="https://hubs.ly/H0f30Lf0" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/kloudless-plus-text.png)">Kloudless</a></li>
|
||||
<li><a href="https://lightsonsoftware.com" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/lightson-dark.png)">Lights On Software</a></li>
|
||||
<li><a href="https://retool.com/?utm_source=djangorest&utm_medium=sponsorship" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/retool-sidebar.png)">Retool</a></li>
|
||||
<li><a href="https://bit.io/jobs?utm_source=DRF&utm_medium=sponsor&utm_campaign=DRF_sponsorship" style="background-image: url(https://fund-rest-framework.s3.amazonaws.com/bit-io.png)">bit.io</a></li>
|
||||
</ul>
|
||||
|
||||
<div style="clear: both; padding-bottom: 20px;"></div>
|
||||
|
||||
<p><em>Many thanks to all our <a href="https://fund.django-rest-framework.org/topics/funding/#our-sponsors">wonderful sponsors</a>, and in particular to our premium backers, <a href="https://getsentry.com/welcome/">Sentry</a>, <a href="https://getstream.io/?utm_source=drf&utm_medium=banner&utm_campaign=drf">Stream</a>, <a href="https://software.esg-usa.com/">ESG</a>, <a href="https://rollbar.com/?utm_source=django&utm_medium=sponsorship&utm_campaign=freetrial">Rollbar</a>, <a href="https://cadre.com">Cadre</a>, <a href="https://hubs.ly/H0f30Lf0">Kloudless</a>, <a href="https://lightsonsoftware.com">Lights On Software</a>, and <a href="https://retool.com/?utm_source=djangorest&utm_medium=sponsorship">Retool</a>.</em></p>
|
||||
<p><em>Many thanks to all our <a href="https://fund.django-rest-framework.org/topics/funding/#our-sponsors">wonderful sponsors</a>, and in particular to our premium backers, <a href="https://getsentry.com/welcome/">Sentry</a>, <a href="https://getstream.io/?utm_source=drf&utm_medium=banner&utm_campaign=drf">Stream</a>, <a href="https://software.esg-usa.com/">ESG</a>, <a href="https://rollbar.com/?utm_source=django&utm_medium=sponsorship&utm_campaign=freetrial">Rollbar</a>, <a href="https://cadre.com">Cadre</a>, <a href="https://hubs.ly/H0f30Lf0">Kloudless</a>, <a href="https://lightsonsoftware.com">Lights On Software</a>, <a href="https://retool.com/?utm_source=djangorest&utm_medium=sponsorship">Retool</a>, and <a href="https://bit.io/jobs?utm_source=DRF&utm_medium=sponsor&utm_campaign=DRF_sponsorship">bit.io</a>.</em></p>
|
||||
<hr />
|
||||
<h2 id="requirements"><a class="toclink" href="#requirements">Requirements</a></h2>
|
||||
<p>REST framework requires the following:</p>
|
||||
<ul>
|
||||
<li>Python (3.5, 3.6, 3.7, 3.8)</li>
|
||||
<li>Django (1.11, 2.0, 2.1, 2.2, 3.0)</li>
|
||||
<li>Django (2.2, 3.0)</li>
|
||||
</ul>
|
||||
<p>We <strong>highly recommend</strong> and only officially support the latest patch release of
|
||||
each Python and Django series.</p>
|
||||
<p>The following packages are optional:</p>
|
||||
<ul>
|
||||
<li><a href="https://pypi.org/project/coreapi/">coreapi</a> (1.32.0+) - Schema generation support.</li>
|
||||
<li><a href="https://pypi.org/project/PyYAML/">PyYAML</a>, <a href="https://pypi.org/project/uritemplate/">uritemplate</a> (5.1+, 3.0.0+) - Schema generation support.</li>
|
||||
<li><a href="https://pypi.org/project/Markdown/">Markdown</a> (3.0.0+) - Markdown support for the browsable API.</li>
|
||||
<li><a href="https://pypi.org/project/Pygments/">Pygments</a> (2.4.0+) - Add syntax highlighting to Markdown processing.</li>
|
||||
<li><a href="https://pypi.org/project/django-filter/">django-filter</a> (1.0.1+) - Filtering support.</li>
|
||||
|
@ -611,7 +599,7 @@ pip install django-filter # Filtering support
|
|||
<p>Don't forget to make sure you've also added <code>rest_framework</code> to your <code>INSTALLED_APPS</code>.</p>
|
||||
<p>We're ready to create our API now.
|
||||
Here's our project's root <code>urls.py</code> module:</p>
|
||||
<pre><code>from django.conf.urls import url, include
|
||||
<pre><code>from django.urls import path, include
|
||||
from django.contrib.auth.models import User
|
||||
from rest_framework import routers, serializers, viewsets
|
||||
|
||||
|
@ -633,8 +621,8 @@ router.register(r'users', UserViewSet)
|
|||
# Wire up our API using automatic URL routing.
|
||||
# Additionally, we include login URLs for the browsable API.
|
||||
urlpatterns = [
|
||||
url(r'^', include(router.urls)),
|
||||
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
|
||||
path('', include(router.urls)),
|
||||
path('api-auth/', include('rest_framework.urls', namespace='rest_framework'))
|
||||
]
|
||||
</code></pre>
|
||||
<p>You can now open the API in your browser at <a href="http://127.0.0.1:8000/">http://127.0.0.1:8000/</a>, and view your new 'users' API. If you use the login control in the top right corner you'll also be able to add, create and delete users from the system.</p>
|
||||
|
@ -702,10 +690,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
|
|||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script async src="https://fund.django-rest-framework.org/sidebar_include.js"></script>
|
||||
<script src="./js/jquery-1.8.1-min.js"></script>
|
||||
<script src="./js/prettify-1.0.js"></script>
|
||||
<script src="./js/bootstrap-2.1.1-min.js"></script>
|
||||
<script src="./js/theme.js"></script>
|
||||
<script src="js/jquery-1.8.1-min.js"></script>
|
||||
<script src="js/prettify-1.0.js"></script>
|
||||
<script src="js/bootstrap-2.1.1-min.js"></script>
|
||||
<script src="js/theme.js"></script>
|
||||
|
||||
<script>var base_url = '.';</script>
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
130
sitemap.xml
130
sitemap.xml
|
@ -2,327 +2,327 @@
|
|||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/tutorial/quickstart/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/tutorial/1-serialization/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/tutorial/2-requests-and-responses/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/tutorial/3-class-based-views/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/tutorial/4-authentication-and-permissions/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/tutorial/5-relationships-and-hyperlinked-apis/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/tutorial/6-viewsets-and-routers/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/requests/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/responses/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/views/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/generic-views/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/viewsets/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/routers/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/parsers/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/renderers/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/serializers/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/fields/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/relations/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/validators/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/authentication/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/permissions/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/caching/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/throttling/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/filtering/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/pagination/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/versioning/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/content-negotiation/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/metadata/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/schemas/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/format-suffixes/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/reverse/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/exceptions/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/status-codes/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/testing/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/api-guide/settings/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/topics/documenting-your-api/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/topics/api-clients/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/topics/internationalization/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/topics/ajax-csrf-cors/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/topics/html-and-forms/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/topics/browser-enhancements/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/topics/browsable-api/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/topics/rest-hypermedia-hateoas/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/tutorials-and-resources/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/third-party-packages/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/contributing/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/project-management/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/release-notes/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/3.11-announcement/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/3.10-announcement/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/3.9-announcement/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/3.8-announcement/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/3.7-announcement/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/3.6-announcement/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/3.5-announcement/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/3.4-announcement/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/3.3-announcement/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/3.2-announcement/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/3.1-announcement/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/3.0-announcement/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/kickstarter-announcement/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/mozilla-grant/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/funding/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://www.django-rest-framework.org/community/jobs/</loc>
|
||||
<lastmod>2020-06-02</lastmod>
|
||||
<lastmod>2020-07-29</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
</urlset>
|
BIN
sitemap.xml.gz
BIN
sitemap.xml.gz
Binary file not shown.
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -797,7 +793,7 @@ that modify the outgoing requests.</p>
|
|||
|
||||
urlpatterns = [
|
||||
...
|
||||
url(r'^docs/', include_docs_urls(title='My API service'))
|
||||
url(r'^docs/', include_docs_urls(title='My API service'), name='api-docs'),
|
||||
]
|
||||
</code></pre>
|
||||
<p>Once the API documentation URLs are installed, you'll be able to include both the required JavaScript resources. Note that the ordering of these two lines is important, as the schema loading requires CoreAPI to already be installed.</p>
|
||||
|
@ -812,12 +808,12 @@ urlpatterns = [
|
|||
<script src="{% url 'api-docs:schema-js' %}"></script>
|
||||
</code></pre>
|
||||
<p>The <code>coreapi</code> library, and the <code>schema</code> object will now both be available on the <code>window</code> instance.</p>
|
||||
<pre><code>const coreapi = window.coreapi
|
||||
const schema = window.schema
|
||||
<pre><code>const coreapi = window.coreapi;
|
||||
const schema = window.schema;
|
||||
</code></pre>
|
||||
<h2 id="instantiating-a-client"><a class="toclink" href="#instantiating-a-client">Instantiating a client</a></h2>
|
||||
<p>In order to interact with the API you'll need a client instance.</p>
|
||||
<pre><code>var client = new coreapi.Client()
|
||||
<pre><code>var client = new coreapi.Client();
|
||||
</code></pre>
|
||||
<p>Typically you'll also want to provide some authentication credentials when
|
||||
instantiating the client.</p>
|
||||
|
@ -827,9 +823,9 @@ authentication. You'll want to provide a standard HTML login flow, to allow
|
|||
the user to login, and then instantiate a client using session authentication:</p>
|
||||
<pre><code>let auth = new coreapi.auth.SessionAuthentication({
|
||||
csrfCookieName: 'csrftoken',
|
||||
csrfHeaderName: 'X-CSRFToken'
|
||||
})
|
||||
let client = new coreapi.Client({auth: auth})
|
||||
csrfHeaderName: 'X-CSRFToken',
|
||||
});
|
||||
let client = new coreapi.Client({auth: auth});
|
||||
</code></pre>
|
||||
<p>The authentication scheme will handle including a CSRF header in any outgoing
|
||||
requests for unsafe HTTP methods.</p>
|
||||
|
@ -837,10 +833,10 @@ requests for unsafe HTTP methods.</p>
|
|||
<p>The <code>TokenAuthentication</code> class can be used to support REST framework's built-in
|
||||
<code>TokenAuthentication</code>, as well as OAuth and JWT schemes.</p>
|
||||
<pre><code>let auth = new coreapi.auth.TokenAuthentication({
|
||||
scheme: 'JWT'
|
||||
token: '<token>'
|
||||
})
|
||||
let client = new coreapi.Client({auth: auth})
|
||||
scheme: 'JWT',
|
||||
token: '<token>',
|
||||
});
|
||||
let client = new coreapi.Client({auth: auth});
|
||||
</code></pre>
|
||||
<p>When using TokenAuthentication you'll probably need to implement a login flow
|
||||
using the CoreAPI client.</p>
|
||||
|
@ -848,20 +844,20 @@ using the CoreAPI client.</p>
|
|||
request to an "obtain token" endpoint</p>
|
||||
<p>For example, using the "Django REST framework JWT" package</p>
|
||||
<pre><code>// Setup some globally accessible state
|
||||
window.client = new coreapi.Client()
|
||||
window.loggedIn = false
|
||||
window.client = new coreapi.Client();
|
||||
window.loggedIn = false;
|
||||
|
||||
function loginUser(username, password) {
|
||||
let action = ["api-token-auth", "obtain-token"]
|
||||
let params = {username: "example", email: "example@example.com"}
|
||||
let action = ["api-token-auth", "obtain-token"];
|
||||
let params = {username: "example", email: "example@example.com"};
|
||||
client.action(schema, action, params).then(function(result) {
|
||||
// On success, instantiate an authenticated client.
|
||||
let auth = window.coreapi.auth.TokenAuthentication({
|
||||
scheme: 'JWT',
|
||||
token: result['token']
|
||||
token: result['token'],
|
||||
})
|
||||
window.client = coreapi.Client({auth: auth})
|
||||
window.loggedIn = true
|
||||
window.client = coreapi.Client({auth: auth});
|
||||
window.loggedIn = true;
|
||||
}).catch(function (error) {
|
||||
// Handle error case where eg. user provides incorrect credentials.
|
||||
})
|
||||
|
@ -871,20 +867,20 @@ function loginUser(username, password) {
|
|||
<p>The <code>BasicAuthentication</code> class can be used to support HTTP Basic Authentication.</p>
|
||||
<pre><code>let auth = new coreapi.auth.BasicAuthentication({
|
||||
username: '<username>',
|
||||
password: '<password>'
|
||||
password: '<password>',
|
||||
})
|
||||
let client = new coreapi.Client({auth: auth})
|
||||
let client = new coreapi.Client({auth: auth});
|
||||
</code></pre>
|
||||
<h2 id="using-the-client"><a class="toclink" href="#using-the-client">Using the client</a></h2>
|
||||
<p>Making requests:</p>
|
||||
<pre><code>let action = ["users", "list"]
|
||||
<pre><code>let action = ["users", "list"];
|
||||
client.action(schema, action).then(function(result) {
|
||||
// Return value is in 'result'
|
||||
})
|
||||
</code></pre>
|
||||
<p>Including parameters:</p>
|
||||
<pre><code>let action = ["users", "create"]
|
||||
let params = {username: "example", email: "example@example.com"}
|
||||
<pre><code>let action = ["users", "create"];
|
||||
let params = {username: "example", email: "example@example.com"};
|
||||
client.action(schema, action, params).then(function(result) {
|
||||
// Return value is in 'result'
|
||||
})
|
||||
|
@ -903,12 +899,12 @@ $ node
|
|||
const coreapi = require('coreapi')
|
||||
</code></pre>
|
||||
<p>You'll either want to include the API schema in your codebase directly, by copying it from the <code>schema.js</code> resource, or else load the schema asynchronously. For example:</p>
|
||||
<pre><code>let client = new coreapi.Client()
|
||||
let schema = null
|
||||
<pre><code>let client = new coreapi.Client();
|
||||
let schema = null;
|
||||
client.get("https://api.example.org/").then(function(data) {
|
||||
// Load a CoreJSON API schema.
|
||||
schema = data
|
||||
console.log('schema loaded')
|
||||
schema = data;
|
||||
console.log('schema loaded');
|
||||
})
|
||||
</code></pre>
|
||||
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -477,7 +473,11 @@ this:</p>
|
|||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIBundle.SwaggerUIStandalonePreset
|
||||
],
|
||||
layout: "BaseLayout"
|
||||
layout: "BaseLayout",
|
||||
requestInterceptor: (request) => {
|
||||
request.headers['X-CSRFToken'] = "{{ csrf_token }}"
|
||||
return request;
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -477,7 +473,7 @@ request.data # Handles arbitrary data. Works for 'POST', 'PUT' and 'PATCH' met
|
|||
<li>The <code>APIView</code> class for working with class-based views.</li>
|
||||
</ol>
|
||||
<p>These wrappers provide a few bits of functionality such as making sure you receive <code>Request</code> instances in your view, and adding context to <code>Response</code> objects so that content negotiation can be performed.</p>
|
||||
<p>The wrappers also provide behaviour such as returning <code>405 Method Not Allowed</code> responses when appropriate, and handling any <code>ParseError</code> exception that occurs when accessing <code>request.data</code> with malformed input.</p>
|
||||
<p>The wrappers also provide behaviour such as returning <code>405 Method Not Allowed</code> responses when appropriate, and handling any <code>ParseError</code> exceptions that occur when accessing <code>request.data</code> with malformed input.</p>
|
||||
<h2 id="pulling-it-all-together"><a class="toclink" href="#pulling-it-all-together">Pulling it all together</a></h2>
|
||||
<p>Okay, let's go ahead and start using these new components to refactor our views slightly.</p>
|
||||
<pre><code>from rest_framework import status
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
<link href="../../css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="../../css/default.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
|
@ -525,6 +521,7 @@ class GroupSerializer(serializers.HyperlinkedModelSerializer):
|
|||
<p>Right, we'd better write some views then. Open <code>tutorial/quickstart/views.py</code> and get typing.</p>
|
||||
<pre><code>from django.contrib.auth.models import User, Group
|
||||
from rest_framework import viewsets
|
||||
from rest_framework import permissions
|
||||
from tutorial.quickstart.serializers import UserSerializer, GroupSerializer
|
||||
|
||||
|
||||
|
@ -534,6 +531,7 @@ class UserViewSet(viewsets.ModelViewSet):
|
|||
"""
|
||||
queryset = User.objects.all().order_by('-date_joined')
|
||||
serializer_class = UserSerializer
|
||||
permission_classes = [permissions.IsAuthenticated]
|
||||
|
||||
|
||||
class GroupViewSet(viewsets.ModelViewSet):
|
||||
|
@ -542,6 +540,7 @@ class GroupViewSet(viewsets.ModelViewSet):
|
|||
"""
|
||||
queryset = Group.objects.all()
|
||||
serializer_class = GroupSerializer
|
||||
permission_classes = [permissions.IsAuthenticated]
|
||||
</code></pre>
|
||||
<p>Rather than write multiple views we're grouping together all the common behavior into classes called <code>ViewSets</code>.</p>
|
||||
<p>We can easily break these down into individual views if we need to, but using viewsets keeps the view logic nicely organized as well as being very concise.</p>
|
||||
|
@ -636,7 +635,7 @@ HTTP/1.1 200 OK
|
|||
<p><img alt="Quick start image" src="../../img/quickstart.png" /></p>
|
||||
<p>If you're working through the browser, make sure to login using the control in the top right corner.</p>
|
||||
<p>Great, that was easy!</p>
|
||||
<p>If you want to get a more in depth understanding of how REST framework fits together head on over to <a href="../1-serialization/">the tutorial</a>, or start browsing the <a href="../#api-guide">API guide</a>.</p>
|
||||
<p>If you want to get a more in depth understanding of how REST framework fits together head on over to <a href="../1-serialization/">the tutorial</a>, or start browsing the <a href="../../api-guide/requests/">API guide</a>.</p>
|
||||
|
||||
|
||||
</div> <!--/span-->
|
||||
|
|
Loading…
Reference in New Issue
Block a user