mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-03-27 21:34:25 +03:00
Update documentation
This commit is contained in:
parent
69194018d5
commit
7e0bfe5a7d
|
@ -754,7 +754,7 @@ color_channel = serializers.ChoiceField(
|
|||
<p>Format strings may either be <a href="http://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior">Python strftime formats</a> which explicitly specify the format, or the special string <code>'iso-8601'</code>, which indicates that <a href="http://www.w3.org/TR/NOTE-datetime">ISO 8601</a> style datetimes should be used. (eg <code>'2013-01-29T12:34:56.000000Z'</code>)</p>
|
||||
<p>When a value of <code>None</code> is used for the format <code>datetime</code> objects will be returned by <code>to_representation</code> and the final output representation will determined by the renderer class.</p>
|
||||
<p>In the case of JSON this means the default datetime representation uses the <a href="http://ecma-international.org/ecma-262/5.1/#sec-15.9.1.15">ECMA 262 date time string specification</a>. This is a subset of ISO 8601 which uses millisecond precision, and includes the 'Z' suffix for the UTC timezone, for example: <code>2013-01-29T12:34:56.123Z</code>.</p>
|
||||
<h4 id="auto_now-and-auto_now_add-model-fields"><a class="toclink" href="#auto_now-and-auto_now_add-model-fields"><code>auto_now</code> and <code>auto_now_add</code> model fields.</a></h4>
|
||||
<h4 id="auto_now-and-auto_now_add-model-fields"><code>auto_now_add</code> model fields.<a class="toclink" href="#auto_now-and-auto_now_add-model-fields"><code>auto_now</code> and </a></h4>
|
||||
<p>When using <code>ModelSerializer</code> or <code>HyperlinkedModelSerializer</code>, note that any model fields with <code>auto_now=True</code> or <code>auto_now_add=True</code> will use serializer fields that are <code>read_only=True</code> by default.</p>
|
||||
<p>If you want to override this behavior, you'll need to declare the <code>DateTimeField</code> explicitly on the serializer. For example:</p>
|
||||
<pre><code>class CommentSerializer(serializers.ModelSerializer):
|
||||
|
@ -949,7 +949,7 @@ class ColorField(serializers.Field):
|
|||
return Color(red, green, blue)
|
||||
</code></pre>
|
||||
<p>By default field values are treated as mapping to an attribute on the object. If you need to customize how the field value is accessed and set you need to override <code>.get_attribute()</code> and/or <code>.get_value()</code>.</p>
|
||||
<p>As an example, let's create a field that can be used represent the class name of the object being serialized:</p>
|
||||
<p>As an example, let's create a field that can be used to represent the class name of the object being serialized:</p>
|
||||
<pre><code>class ClassNameField(serializers.Field):
|
||||
def get_attribute(self, obj):
|
||||
# We pass the object instance onto `to_representation`,
|
||||
|
|
|
@ -558,10 +558,10 @@ class UserListView(generics.ListAPIView):
|
|||
<p>To use REST framework's <code>DjangoFilterBackend</code>, first install <code>django-filter</code>.</p>
|
||||
<pre><code>pip install django-filter
|
||||
</code></pre>
|
||||
<p>If you are using the browsable API or admin API you may also want to install <code>crispy-forms</code>, which will enhance the presentation of the filter forms in HTML views, by allowing them to render Bootstrap 3 HTML.</p>
|
||||
<p>If you are using the browsable API or admin API you may also want to install <code>django-crispy-forms</code>, which will enhance the presentation of the filter forms in HTML views, by allowing them to render Bootstrap 3 HTML.</p>
|
||||
<pre><code>pip install django-crispy-forms
|
||||
</code></pre>
|
||||
<p>With crispy forms installed, the browsable API will present a filtering control for <code>DjangoFilterBackend</code>, like so:</p>
|
||||
<p>With crispy forms installed and added to Django's <code>INSTALLED_APPS</code>, the browsable API will present a filtering control for <code>DjangoFilterBackend</code>, like so:</p>
|
||||
<p><img alt="Django Filter" src="../../img/django-filter.png" /></p>
|
||||
<h4 id="specifying-filter-fields"><a class="toclink" href="#specifying-filter-fields">Specifying filter fields</a></h4>
|
||||
<p>If all you need is simple equality-based filtering, you can set a <code>filter_fields</code> attribute on the view, or viewset, listing the set of fields you wish to filter against.</p>
|
||||
|
|
|
@ -510,14 +510,6 @@ class UserList(generics.ListCreateAPIView):
|
|||
serializer_class = UserSerializer
|
||||
permission_classes = (IsAdminUser,)
|
||||
|
||||
def get_paginate_by(self):
|
||||
"""
|
||||
Use smaller pagination for HTML representations.
|
||||
"""
|
||||
if self.request.accepted_renderer.format == 'html':
|
||||
return 20
|
||||
return 100
|
||||
|
||||
def list(self, request):
|
||||
# Note the use of `get_queryset()` instead of `self.queryset`
|
||||
queryset = self.get_queryset()
|
||||
|
@ -602,15 +594,6 @@ class UserList(generics.ListCreateAPIView):
|
|||
return FullAccountSerializer
|
||||
return BasicAccountSerializer
|
||||
</code></pre>
|
||||
<h4 id="get_paginate_byself"><a class="toclink" href="#get_paginate_byself"><code>get_paginate_by(self)</code></a></h4>
|
||||
<p>Returns the page size to use with pagination. By default this uses the <code>paginate_by</code> attribute, and may be overridden by the client if the <code>paginate_by_param</code> attribute is set.</p>
|
||||
<p>You may want to override this method to provide more complex behavior, such as modifying page sizes based on the media type of the response.</p>
|
||||
<p>For example:</p>
|
||||
<pre><code>def get_paginate_by(self):
|
||||
if self.request.accepted_renderer.format == 'html':
|
||||
return 20
|
||||
return 100
|
||||
</code></pre>
|
||||
<p><strong>Save and deletion hooks</strong>:</p>
|
||||
<p>The following methods are provided by the mixin classes, and provide easy overriding of the object save or deletion behavior.</p>
|
||||
<ul>
|
||||
|
|
|
@ -440,6 +440,7 @@
|
|||
</ul>
|
||||
<p>The built-in styles currently all use links included as part of the content of the response. This style is more accessible when using the browsable API.</p>
|
||||
<p>Pagination is only performed automatically if you're using the generic views or viewsets. If you're using a regular <code>APIView</code>, you'll need to call into the pagination API yourself to ensure you return a paginated response. See the source code for the <code>mixins.ListModelMixin</code> and <code>generics.GenericAPIView</code> classes for an example.</p>
|
||||
<p>Pagination can be turned off by setting the pagination class to <code>None</code>.</p>
|
||||
<h2 id="setting-the-pagination-style"><a class="toclink" href="#setting-the-pagination-style">Setting the pagination style</a></h2>
|
||||
<p>The default pagination style may be set globally, using the <code>DEFAULT_PAGINATION_CLASS</code> settings key. For example, to use the built-in limit/offset pagination, you would do:</p>
|
||||
<pre><code>REST_FRAMEWORK = {
|
||||
|
@ -500,6 +501,7 @@ class StandardResultsSetPagination(PageNumberPagination):
|
|||
<p>The <code>PageNumberPagination</code> class includes a number of attributes that may be overridden to modify the pagination style.</p>
|
||||
<p>To set these attributes you should override the <code>PageNumberPagination</code> class, and then enable your custom pagination class as above.</p>
|
||||
<ul>
|
||||
<li><code>django_paginator_class</code> - The Django Paginator class to use. Default is <code>django.core.paginator.Paginator</code>, which should be fine for most usecases.</li>
|
||||
<li><code>page_size</code> - A numeric value indicating the page size. If set, this overrides the <code>PAGE_SIZE</code> setting. Defaults to the same value as the <code>PAGE_SIZE</code> settings key.</li>
|
||||
<li><code>page_query_param</code> - A string value indicating the name of the query parameter to use for the pagination control.</li>
|
||||
<li><code>page_size_query_param</code> - If set, this is a string value indicating the name of a query parameter that allows the client to set the page size on a per-request basis. Defaults to <code>None</code>, indicating that the client may not control the requested page size.</li>
|
||||
|
|
|
@ -476,7 +476,10 @@ class ExampleView(APIView):
|
|||
return Response({'received data': request.data})
|
||||
</code></pre>
|
||||
<p>Or, if you're using the <code>@api_view</code> decorator with function based views.</p>
|
||||
<pre><code>@api_view(['POST'])
|
||||
<pre><code>from rest_framework.decorators import api_view
|
||||
from rest_framework.decorators import parser_classes
|
||||
|
||||
@api_view(['POST'])
|
||||
@parser_classes((JSONParser,))
|
||||
def example_view(request, format=None):
|
||||
"""
|
||||
|
|
|
@ -625,6 +625,13 @@ def simple_html_view(request):
|
|||
<p><img alt="The AdminRender view" src="../../img/admin.png" /></p>
|
||||
<p>This renderer is suitable for CRUD-style web APIs that should also present a user-friendly interface for managing the data.</p>
|
||||
<p>Note that views that have nested or list serializers for their input won't work well with the <code>AdminRenderer</code>, as the HTML forms are unable to properly support them.</p>
|
||||
<p><strong>Note</strong>: The <code>AdminRenderer</code> is only able to include links to detail pages when a properly configured <code>URL_FIELD_NAME</code> (<code>url</code> by default) attribute is present in the data. For <code>HyperlinkedModelSerializer</code> this will be the case, but for <code>ModelSerializer</code> or plain <code>Serializer</code> classes you'll need to make sure to include the field explicitly. For example here we use models <code>get_absolute_url</code> method:</p>
|
||||
<pre><code>class AccountSerializer(serializers.ModelSerializer):
|
||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Account
|
||||
</code></pre>
|
||||
<p><strong>.media_type</strong>: <code>text/html</code></p>
|
||||
<p><strong>.format</strong>: <code>'.admin'</code></p>
|
||||
<p><strong>.charset</strong>: <code>utf-8</code></p>
|
||||
|
|
|
@ -1148,6 +1148,10 @@ class BookSerializer(serializers.Serializer):
|
|||
return ret
|
||||
|
||||
class BookSerializer(serializers.Serializer):
|
||||
# We need to identify elements in the list using their primary key,
|
||||
# so use a writable field here, rather than the default which would be read-only.
|
||||
id = serializers.IntegerField()
|
||||
|
||||
...
|
||||
class Meta:
|
||||
list_serializer_class = BookListSerializer
|
||||
|
|
|
@ -504,12 +504,12 @@ Accept: application/json
|
|||
<p>Your URL conf must include a pattern that matches the version with a <code>'version'</code> keyword argument, so that this information is available to the versioning scheme.</p>
|
||||
<pre><code>urlpatterns = [
|
||||
url(
|
||||
r'^(?P<version>[v1|v2]+)/bookings/$',
|
||||
r'^(?P<version>(v1|v2))/bookings/$',
|
||||
bookings_list,
|
||||
name='bookings-list'
|
||||
),
|
||||
url(
|
||||
r'^(?P<version>[v1|v2]+)/bookings/(?P<pk>[0-9]+)/$',
|
||||
r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$',
|
||||
bookings_detail,
|
||||
name='bookings-detail'
|
||||
)
|
||||
|
|
|
@ -477,7 +477,7 @@
|
|||
<ul>
|
||||
<li><a href="http://pypi.python.org/pypi/Markdown/">Markdown</a> (2.1.0+) - Markdown support for the browsable API.</li>
|
||||
<li><a href="http://pypi.python.org/pypi/django-filter">django-filter</a> (0.9.2+) - Filtering support.</li>
|
||||
<li>[django-crispy-forms][django-crispy-forms] - Improved HTML display for filtering.</li>
|
||||
<li><a href="https://github.com/maraujop/django-crispy-forms">django-crispy-forms</a> - Improved HTML display for filtering.</li>
|
||||
<li><a href="https://github.com/lukaszb/django-guardian">django-guardian</a> (1.1.1+) - Object level permissions support.</li>
|
||||
</ul>
|
||||
<h2 id="installation"><a class="toclink" href="#installation">Installation</a></h2>
|
||||
|
@ -501,7 +501,7 @@ pip install django-filter # Filtering support
|
|||
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
|
||||
]
|
||||
</code></pre>
|
||||
<p>Note that the URL path can be whatever you want, but you must include <code>'rest_framework.urls'</code> with the <code>'rest_framework'</code> namespace.</p>
|
||||
<p>Note that the URL path can be whatever you want, but you must include <code>'rest_framework.urls'</code> with the <code>'rest_framework'</code> namespace. You may leave out the namespace in Django 1.9+, and REST framework will set it for you.</p>
|
||||
<h2 id="example"><a class="toclink" href="#example">Example</a></h2>
|
||||
<p>Let's take a look at a quick example of using REST framework to build a simple model-backed API.</p>
|
||||
<p>We'll create a read-write API for accessing information on the users of our project.</p>
|
||||
|
|
File diff suppressed because one or more lines are too long
100
sitemap.xml
100
sitemap.xml
|
@ -4,7 +4,7 @@
|
|||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
|
@ -13,43 +13,43 @@
|
|||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//tutorial/quickstart/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//tutorial/1-serialization/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//tutorial/2-requests-and-responses/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//tutorial/3-class-based-views/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//tutorial/4-authentication-and-permissions/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//tutorial/5-relationships-and-hyperlinked-apis/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//tutorial/6-viewsets-and-routers/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
|
@ -59,157 +59,157 @@
|
|||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/requests/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/responses/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/views/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/generic-views/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/viewsets/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/routers/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/parsers/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/renderers/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/serializers/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/fields/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/relations/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/validators/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/authentication/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/permissions/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/throttling/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/filtering/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/pagination/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/versioning/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/content-negotiation/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/metadata/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/format-suffixes/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/reverse/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/exceptions/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/status-codes/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/testing/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//api-guide/settings/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
|
@ -219,97 +219,97 @@
|
|||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/documenting-your-api/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/internationalization/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/ajax-csrf-cors/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/html-and-forms/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/browser-enhancements/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/browsable-api/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/rest-hypermedia-hateoas/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/third-party-resources/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/contributing/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/project-management/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/3.0-announcement/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/3.1-announcement/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/3.2-announcement/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/3.3-announcement/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/kickstarter-announcement/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>http://www.django-rest-framework.org//topics/release-notes/</loc>
|
||||
<lastmod>2015-11-04</lastmod>
|
||||
<lastmod>2015-12-14</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
|
|
|
@ -426,7 +426,7 @@
|
|||
<hr />
|
||||
<p><em>Below is an in-depth guide to the API changes and migration notes for 3.0.</em></p>
|
||||
<h2 id="request-objects"><a class="toclink" href="#request-objects">Request objects</a></h2>
|
||||
<h4 id="the-data-and-query_params-properties"><a class="toclink" href="#the-data-and-query_params-properties">The <code>.data</code> and <code>.query_params</code> properties.</a></h4>
|
||||
<h4 id="the-data-and-query_params-properties"><code>.query_params</code> properties.<a class="toclink" href="#the-data-and-query_params-properties">The <code>.data</code> and </a></h4>
|
||||
<p>The usage of <code>request.DATA</code> and <code>request.FILES</code> is now pending deprecation in favor of a single <code>request.data</code> attribute that contains <em>all</em> the parsed data.</p>
|
||||
<p>Having separate attributes is reasonable for web applications that only ever parse url-encoded or multipart requests, but makes less sense for the general-purpose request parsing that REST framework supports.</p>
|
||||
<p>You may now pass all the request data to a serializer class in a single argument:</p>
|
||||
|
@ -458,7 +458,7 @@ ExampleSerializer(data=request.DATA, files=request.FILES)
|
|||
<li>Calling <code>serializer.save()</code> then saves and returns the new object instance.</li>
|
||||
</ol>
|
||||
<p>The resulting API changes are further detailed below.</p>
|
||||
<h4 id="the-create-and-update-methods"><a class="toclink" href="#the-create-and-update-methods">The <code>.create()</code> and <code>.update()</code> methods.</a></h4>
|
||||
<h4 id="the-create-and-update-methods"><code>.update()</code> methods.<a class="toclink" href="#the-create-and-update-methods">The <code>.create()</code> and </a></h4>
|
||||
<p>The <code>.restore_object()</code> method is now removed, and we instead have two separate methods, <code>.create()</code> and <code>.update()</code>. These methods work slightly different to the previous <code>.restore_object()</code>.</p>
|
||||
<p>When using the <code>.create()</code> and <code>.update()</code> methods you should both create <em>and save</em> the object instance. This is in contrast to the previous <code>.restore_object()</code> behavior that would instantiate the object but not save it.</p>
|
||||
<p>These methods also replace the optional <code>.save_object()</code> method, which no longer exists.</p>
|
||||
|
@ -490,7 +490,7 @@ def create(self, validated_data):
|
|||
return Snippet.objects.create(**validated_data)
|
||||
</code></pre>
|
||||
<p>Note that these methods should return the newly created object instance.</p>
|
||||
<h4 id="use-validated_data-instead-of-object"><a class="toclink" href="#use-validated_data-instead-of-object">Use <code>.validated_data</code> instead of <code>.object</code>.</a></h4>
|
||||
<h4 id="use-validated_data-instead-of-object"><code>.object</code>.<a class="toclink" href="#use-validated_data-instead-of-object">Use <code>.validated_data</code> instead of </a></h4>
|
||||
<p>You must now use the <code>.validated_data</code> attribute if you need to inspect the data before saving, rather than using the <code>.object</code> attribute, which no longer exists.</p>
|
||||
<p>For example the following code <em>is no longer valid</em>:</p>
|
||||
<pre><code>if serializer.is_valid():
|
||||
|
@ -838,7 +838,7 @@ def all_high_scores(request):
|
|||
</code></pre>
|
||||
<hr />
|
||||
<h2 id="serializer-fields"><a class="toclink" href="#serializer-fields">Serializer fields</a></h2>
|
||||
<h4 id="the-field-and-readonly-field-classes"><a class="toclink" href="#the-field-and-readonly-field-classes">The <code>Field</code> and <code>ReadOnly</code> field classes.</a></h4>
|
||||
<h4 id="the-field-and-readonly-field-classes"><code>ReadOnly</code> field classes.<a class="toclink" href="#the-field-and-readonly-field-classes">The <code>Field</code> and </a></h4>
|
||||
<p>There are some minor tweaks to the field base classes.</p>
|
||||
<p>Previously we had these two base classes:</p>
|
||||
<ul>
|
||||
|
@ -850,7 +850,7 @@ def all_high_scores(request):
|
|||
<li><code>Field</code> is the base class for all fields. It does not include any default implementation for either serializing or deserializing data.</li>
|
||||
<li><code>ReadOnlyField</code> is a concrete implementation for read-only fields that simply returns the attribute value without modification.</li>
|
||||
</ul>
|
||||
<h4 id="the-required-allow_null-allow_blank-and-default-arguments"><a class="toclink" href="#the-required-allow_null-allow_blank-and-default-arguments">The <code>required</code>, <code>allow_null</code>, <code>allow_blank</code> and <code>default</code> arguments.</a></h4>
|
||||
<h4 id="the-required-allow_null-allow_blank-and-default-arguments"><code>allow_null</code>, <code>default</code> arguments.<a class="toclink" href="#the-required-allow_null-allow_blank-and-default-arguments">The <code>required</code>, <code>allow_blank</code> and </a></h4>
|
||||
<p>REST framework now has more explicit and clear control over validating empty values for fields.</p>
|
||||
<p>Previously the meaning of the <code>required=False</code> keyword argument was underspecified. In practice its use meant that a field could either be not included in the input, or it could be included, but be <code>None</code> or the empty string.</p>
|
||||
<p>We now have a better separation, with separate <code>required</code>, <code>allow_null</code> and <code>allow_blank</code> arguments.</p>
|
||||
|
@ -960,7 +960,7 @@ This removes some magic and makes it easier and more obvious to move between imp
|
|||
<p>The following usage will <em>now raise an error</em>:</p>
|
||||
<pre><code>email = serializers.EmailField(source='email')
|
||||
</code></pre>
|
||||
<h4 id="the-uniquevalidator-and-uniquetogethervalidator-classes"><a class="toclink" href="#the-uniquevalidator-and-uniquetogethervalidator-classes">The <code>UniqueValidator</code> and <code>UniqueTogetherValidator</code> classes.</a></h4>
|
||||
<h4 id="the-uniquevalidator-and-uniquetogethervalidator-classes"><code>UniqueTogetherValidator</code> classes.<a class="toclink" href="#the-uniquevalidator-and-uniquetogethervalidator-classes">The <code>UniqueValidator</code> and </a></h4>
|
||||
<p>REST framework now provides new validators that allow you to ensure field uniqueness, while still using a completely explicit <code>Serializer</code> class instead of using <code>ModelSerializer</code>.</p>
|
||||
<p>The <code>UniqueValidator</code> should be applied to a serializer field, and takes a single <code>queryset</code> argument.</p>
|
||||
<pre><code>from rest_framework import serializers
|
||||
|
|
|
@ -1,729 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Funding - Django REST framework</title>
|
||||
<link href="../../img/favicon.ico" rel="icon" type="image/x-icon">
|
||||
<link rel="canonical" href="http://www.django-rest-framework.org/topics/funding/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="Django, API, REST, Funding">
|
||||
<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">
|
||||
|
||||
<!-- 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 || [];
|
||||
_gaq.push(['_setAccount', 'UA-18852272-2']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script');
|
||||
ga.type = 'text/javascript';
|
||||
ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0];
|
||||
s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
</script>
|
||||
|
||||
<style>
|
||||
span.fusion-wrap a {
|
||||
display: block;
|
||||
margin-top: 10px;
|
||||
color: black;
|
||||
}
|
||||
a.fusion-poweredby {
|
||||
display: block;
|
||||
margin-top: 10px;
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
div.promo {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload="prettyPrint()" class="-page">
|
||||
|
||||
<div class="wrapper">
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="prev" href="../release-notes/">
|
||||
Next <i class="icon-arrow-right icon-white"></i>
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small " rel="next" href="../kickstarter-announcement/">
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a id="search_modal_show" class="repo-link btn btn-inverse btn-small" href="#mkdocs_search_modal" data-toggle="modal" data-target="#mkdocs_search_modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</a>
|
||||
<a class="brand" href="http://www.django-rest-framework.org">Django REST framework</a>
|
||||
<div class="nav-collapse collapse">
|
||||
|
||||
<!-- Main navigation -->
|
||||
<ul class="nav navbar-nav">
|
||||
|
||||
<li >
|
||||
<a href="../..">Home</a>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/quickstart/">Quickstart</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/1-serialization/">1 - Serialization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/2-requests-and-responses/">2 - Requests and responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/3-class-based-views/">3 - Class based views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/4-authentication-and-permissions/">4 - Authentication and permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/5-relationships-and-hyperlinked-apis/">5 - Relationships and hyperlinked APIs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../tutorial/6-viewsets-and-routers/">6 - Viewsets and routers</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">API Guide <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/requests/">Requests</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/responses/">Responses</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/views/">Views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/generic-views/">Generic views</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/viewsets/">Viewsets</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/routers/">Routers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/parsers/">Parsers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/renderers/">Renderers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/serializers/">Serializers</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/fields/">Serializer fields</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/relations/">Serializer relations</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/validators/">Validators</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/authentication/">Authentication</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/permissions/">Permissions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/throttling/">Throttling</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/filtering/">Filtering</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/pagination/">Pagination</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/versioning/">Versioning</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/content-negotiation/">Content negotiation</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/metadata/">Metadata</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/format-suffixes/">Format suffixes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/reverse/">Returning URLs</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/exceptions/">Exceptions</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/status-codes/">Status codes</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/testing/">Testing</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../../api-guide/settings/">Settings</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown active">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Topics <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
||||
<li >
|
||||
<a href="../documenting-your-api/">Documenting your API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../internationalization/">Internationalization</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../ajax-csrf-cors/">AJAX, CSRF & CORS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../html-and-forms/">HTML & Forms</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../browser-enhancements/">Browser Enhancements</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../browsable-api/">The Browsable API</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../rest-hypermedia-hateoas/">REST, Hypermedia & HATEOAS</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../third-party-resources/">Third Party Resources</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../contributing/">Contributing to REST framework</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../project-management/">Project management</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../3.0-announcement/">3.0 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../3.1-announcement/">3.1 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../3.2-announcement/">3.2 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../3.3-announcement/">3.3 Announcement</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../kickstarter-announcement/">Kickstarter Announcement</a>
|
||||
</li>
|
||||
|
||||
<li class="active" >
|
||||
<a href="./">Funding</a>
|
||||
</li>
|
||||
|
||||
<li >
|
||||
<a href="../release-notes/">Release Notes</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="body-content">
|
||||
<div class="container-fluid">
|
||||
<!-- Search Modal -->
|
||||
<div id="mkdocs_search_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">Documentation search</h3>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<form role="form" autocomplete="off">
|
||||
<div class="form-group">
|
||||
<input type="text" name="q" class="form-control" placeholder="Search..." id="mkdocs-search-query">
|
||||
</div>
|
||||
</form>
|
||||
<div id="mkdocs-search-results"></div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span3">
|
||||
<div id="table-of-contents">
|
||||
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||
|
||||
|
||||
|
||||
<li class="main">
|
||||
<a href="#funding">Funding</a>
|
||||
</li>
|
||||
|
||||
|
||||
<li>
|
||||
<a href="#making-the-business-case">Making the business case</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#individual-plan">Individual plan</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#corporate-plans">Corporate plans</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#roadmap">Roadmap</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="main-content" class="span9">
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
// Imperfect, but easier to fit in with the existing docs build.
|
||||
// Hyperlinks should point directly to the "fund." subdomain, but this'll
|
||||
// handle the nav bar links without requiring any docs build changes for the moment.
|
||||
if (window.location.hostname == "www.django-rest-framework.org") {
|
||||
window.location.replace("https://fund.django-rest-framework.org/topics/funding/");
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.chart {
|
||||
background-color: #e3e3e3;
|
||||
background: -webkit-linear-gradient(top, #fff 0, #e3e3e3 100%);
|
||||
border: 1px solid #E6E6E6;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0px 0px 2px 0px rgba(181, 181, 181, 0.3);
|
||||
padding: 40px 0px 5px;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
width: 97%;
|
||||
min-height: 255px;
|
||||
position: relative;
|
||||
top: 37px;
|
||||
margin-bottom: 20px
|
||||
}
|
||||
.quantity {
|
||||
text-align: center
|
||||
}
|
||||
.dollar {
|
||||
font-size: 19px;
|
||||
position: relative;
|
||||
top: -18px;
|
||||
}
|
||||
.price {
|
||||
font-size: 49px;
|
||||
}
|
||||
.period {
|
||||
font-size: 17px;
|
||||
position: relative;
|
||||
top: -8px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
.plan-name {
|
||||
text-align: center;
|
||||
font-size: 20px;
|
||||
font-weight: 400;
|
||||
color: #777;
|
||||
border-bottom: 1px solid #d5d5d5;
|
||||
padding-bottom: 15px;
|
||||
width: 90%;
|
||||
margin: 0 auto;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.specs {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.specs.startup {
|
||||
margin-bottom: 93px
|
||||
}
|
||||
.spec {
|
||||
font-size: 15px;
|
||||
color: #474747;
|
||||
text-align: center;
|
||||
font-weight: 300;
|
||||
margin-bottom: 13px;
|
||||
}
|
||||
.variable {
|
||||
color: #1FBEE7;
|
||||
font-weight: 400;
|
||||
}
|
||||
form.signup {
|
||||
margin-top: 35px
|
||||
}
|
||||
.clear-promo {
|
||||
padding-top: 30px
|
||||
}
|
||||
#main-content h1:first-of-type {
|
||||
margin: 0 0 50px;
|
||||
font-size: 60px;
|
||||
font-weight: 200;
|
||||
text-align: center
|
||||
}
|
||||
#main-content {
|
||||
padding-top: 10px; line-height: 23px
|
||||
}
|
||||
#main-content li {
|
||||
line-height: 23px
|
||||
}
|
||||
</style>
|
||||
|
||||
<h1 id="funding">Funding</h1>
|
||||
<p>If you use REST framework commercially we strongly encourage you to invest in its continued development by signing up for a paid plan.</p>
|
||||
<p><strong>We believe that collaboratively funded software can offer outstanding returns on investment, by allowing users and clients to collectively share the cost of development.</strong></p>
|
||||
<p>Signing up for a paid plan will:</p>
|
||||
<ul>
|
||||
<li>Directly contribute to faster releases, more features and higher quality software.</li>
|
||||
<li>Allow more time to be invested in documentation, issue triage and community support.</li>
|
||||
<li>Safeguard the future development of REST framework.</li>
|
||||
</ul>
|
||||
<p>REST framework will always be open source and permissively licensed, but we firmly believe it is in the commercial best-interest for users of the project to fund its ongoing development.</p>
|
||||
<hr />
|
||||
<h2 id="making-the-business-case">Making the business case</h2>
|
||||
<p>Our successful Kickstarter campaign demonstrates the cost-reward ratio of shared development funding.</p>
|
||||
<p>With <em>typical corporate fundings of just £100-£1000 per organization</em> we successfully delivered:</p>
|
||||
<ul>
|
||||
<li>The comprehensive 3.0 serializer redesign.</li>
|
||||
<li>Substantial improvements to the Browsable API.</li>
|
||||
<li>The admin interface.</li>
|
||||
<li>A new pagination API including offset/limit and cursor pagination implementations, plus on-page controls.</li>
|
||||
<li>A versioning API, including URL-based and header-based versioning schemes.</li>
|
||||
<li>Support for customizable exception handling.</li>
|
||||
<li>Support for Django's PostgreSQL HStoreField, ArrayField and JSONField.</li>
|
||||
<li>Templated HTML form support, including HTML forms with nested list and objects.</li>
|
||||
<li>Internationalization support for API responses, currently with 27 languages.</li>
|
||||
<li>The metadata APIs for handling <code>OPTIONS</code> requests and schema endpoints.</li>
|
||||
<li>Numerous minor improvements and better quality throughout the codebase.</li>
|
||||
<li>Ongoing triage and community support, closing over 1600 tickets.</li>
|
||||
</ul>
|
||||
<p>This incredible level of return on investment is <em>only possible through collaboratively funded models</em>, which is why we believe that supporting our paid plans is in everyone's best interest.</p>
|
||||
<hr />
|
||||
<h2 id="individual-plan">Individual plan</h2>
|
||||
<p>This subscription is recommended for freelancers and other individuals with an interest in seeing REST framework continue to improve.</p>
|
||||
<p>If you are using REST framework as an full-time employee, consider recommending that your company takes out a <a href="#corporate-plans">corporate plan</a>.</p>
|
||||
<div class="pricing">
|
||||
<div class="span4">
|
||||
<div class="chart first">
|
||||
<div class="quantity">
|
||||
<span class="dollar">$</span>
|
||||
<span class="price">15</span>
|
||||
<span class="period">/month</span>
|
||||
</div>
|
||||
<div class="plan-name">Individual</div>
|
||||
<div class="specs">
|
||||
<div class="spec">
|
||||
Support ongoing development
|
||||
</div>
|
||||
<div class="spec">
|
||||
Credited on the site
|
||||
</div>
|
||||
</div>
|
||||
<form class="signup" action="/signup/individual/" method="POST">
|
||||
<script
|
||||
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
|
||||
data-key="{{ stripe_public }}"
|
||||
data-amount="1500"
|
||||
data-name="Django REST framework"
|
||||
data-description="Individual"
|
||||
data-currency="usd"
|
||||
data-allow-remember-me=false
|
||||
data-billing-address=true
|
||||
data-label='Sign up'
|
||||
data-panel-label='Sign up - {% verbatim %}{{amount}}{% endverbatim %}/mo'>
|
||||
</script>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="clear: both; padding-top: 50px"></div>
|
||||
|
||||
<p><em>Billing is monthly and you can cancel at any time.</em></p>
|
||||
<hr />
|
||||
<h2 id="corporate-plans">Corporate plans</h2>
|
||||
<p>These subscriptions are recommended for companies and organizations using REST framework either publicly or privately.</p>
|
||||
<p>In exchange for funding you'll also receive advertising space on our site, allowing you to <strong>promote your company or product to many tens of thousands of developers worldwide</strong>.</p>
|
||||
<p>Our professional and premium plans also include <strong>priority support</strong>. At any time your engineers can escalate an issue or discussion group thread, and we'll ensure it gets a guaranteed response within the next working day.</p>
|
||||
<div class="pricing">
|
||||
<div class="span4">
|
||||
<div class="chart first">
|
||||
<div class="quantity">
|
||||
<span class="dollar">$</span>
|
||||
<span class="price">50</span>
|
||||
<span class="period">/month</span>
|
||||
</div>
|
||||
<div class="plan-name">Basic</div>
|
||||
<div class="specs startup">
|
||||
<div class="spec">
|
||||
Support ongoing development
|
||||
</div>
|
||||
<div class="spec">
|
||||
<span class="variable">Funding page</span> ad placement
|
||||
</div>
|
||||
</div>
|
||||
<form class="signup" action="/signup/startup/" method="POST">
|
||||
<script
|
||||
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
|
||||
data-key="{{ stripe_public }}"
|
||||
data-amount="5000"
|
||||
data-name="Django REST framework"
|
||||
data-description="Basic"
|
||||
data-currency="usd"
|
||||
data-allow-remember-me=false
|
||||
data-billing-address=true
|
||||
data-label='Sign up'
|
||||
data-panel-label='Sign up - {% verbatim %}{{amount}}{% endverbatim %}/mo'>
|
||||
</script>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<div class="chart">
|
||||
<div class="quantity">
|
||||
<span class="dollar">$</span>
|
||||
<span class="price">250</span>
|
||||
<span class="period">/month</span>
|
||||
</div>
|
||||
<div class="plan-name">Professional</div>
|
||||
<div class="specs">
|
||||
<div class="spec">
|
||||
Add a <span class="variable">half day per month</span> development time to the project
|
||||
</div>
|
||||
<div class="spec">
|
||||
<span class="variable">Homepage</span> ad placement
|
||||
</div>
|
||||
<div class="spec">
|
||||
<span class="variable">Priority support</span> for your engineers
|
||||
</div>
|
||||
</div>
|
||||
<form class="signup" action="/signup/professional/" method="POST">
|
||||
<script
|
||||
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
|
||||
data-key="{{ stripe_public }}"
|
||||
data-amount="25000"
|
||||
data-name="Django REST framework"
|
||||
data-description="Professional"
|
||||
data-currency="usd"
|
||||
data-allow-remember-me=false
|
||||
data-billing-address=true
|
||||
data-label='Sign up'
|
||||
data-panel-label='Sign up - {% verbatim %}{{amount}}{% endverbatim %}/mo'>
|
||||
</script>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<div class="chart last">
|
||||
<div class="quantity">
|
||||
<span class="dollar">$</span>
|
||||
<span class="price">500</span>
|
||||
<span class="period">/month</span>
|
||||
</div>
|
||||
<div class="plan-name">Premium</div>
|
||||
<div class="specs">
|
||||
<div class="spec">
|
||||
Add <span class="variable">one full day per month</span> development time to the project
|
||||
</div>
|
||||
<div class="spec">
|
||||
<span class="variable">Full site</span> ad placement
|
||||
</div>
|
||||
<div class="spec">
|
||||
<span class="variable">Priority support</span> for your engineers
|
||||
</div>
|
||||
</div>
|
||||
<form class="signup" action="/signup/premium/" method="POST">
|
||||
<script
|
||||
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
|
||||
data-key="{{ stripe_public }}"
|
||||
data-amount="50000"
|
||||
data-name="Django REST framework"
|
||||
data-description="Premium"
|
||||
data-currency="usd"
|
||||
data-allow-remember-me=false
|
||||
data-billing-address=true
|
||||
data-label='Sign up'
|
||||
data-panel-label='Sign up - {% verbatim %}{{amount}}{% endverbatim %}/mo'>
|
||||
</script>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="clear: both; padding-top: 50px"></div>
|
||||
|
||||
<p><em>Billing is monthly and you can cancel at any time.</em></p>
|
||||
<p>Once you've signed up we'll contact you via email and arrange your ad placements on the site.</p>
|
||||
<p>For further enquires please contact <a href=mailto:tom@tomchristie.com>tom@tomchristie.com</a>.</p>
|
||||
<hr />
|
||||
<h2 id="roadmap">Roadmap</h2>
|
||||
<p>Although we're incredibly proud of REST framework in its current state we believe there is still huge scope for improvement. What we're aiming for here is a <em>highly polished, rock solid product</em>. This needs to backed up with impeccable documentation and a great third party ecosystem.</p>
|
||||
<p>The roadmap below is a broad indication of just some of the ongoing and future work we believe is important to REST framework.</p>
|
||||
<ul>
|
||||
<li>Increasing our "bus factor" through documented organizational process & safeguards.</li>
|
||||
<li>More time towards testing and hardening releases, with only gradual, well-documented deprecations.</li>
|
||||
<li>A formal policy on security backports for non-current releases.</li>
|
||||
<li>Continuing triage & community support.</li>
|
||||
<li>Improved project documentation, including versioned & internationalized docs.</li>
|
||||
<li>Improved third party package visibility.</li>
|
||||
<li>Refining the admin interface, ensuring it has a fully customizable API and making it suitable as end-user facing application.</li>
|
||||
<li>Cleaning up internal complexities including the <code>BrowsableAPIRenderer</code> and <code>Request</code> object.</li>
|
||||
<li>Support for alternative backends such as SQLAlchemy.</li>
|
||||
<li>Support for non-database backed services.</li>
|
||||
<li>HTTP Caching API & support for conditional database lookups.</li>
|
||||
<li>Benchmarking and performance improvements.</li>
|
||||
<li>In depth documentation on advanced usage and best practices.</li>
|
||||
<li>Documentation & support for integration with realtime systems.</li>
|
||||
<li>Hypermedia support and client libraries.</li>
|
||||
<li>Support for JSON schema as endpoints or <code>OPTIONS</code> responses.</li>
|
||||
<li>API metric tools.</li>
|
||||
<li>Debug & logging tools.</li>
|
||||
<li>Third party GraphQL support.</li>
|
||||
</ul>
|
||||
<p>By taking out a paid plan you'll be directly contributing towards making these features happen.</p>
|
||||
|
||||
|
||||
</div> <!--/span-->
|
||||
</div> <!--/row-->
|
||||
</div> <!--/.fluid-container-->
|
||||
</div> <!--/.body content-->
|
||||
<div id="push"></div>
|
||||
</div> <!--/.wrapper -->
|
||||
|
||||
<footer class="span12">
|
||||
<p>Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.
|
||||
</p>
|
||||
</footer>
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<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>var base_url = '../..';</script>
|
||||
<script src="../../mkdocs/js/require.js"></script>
|
||||
<script src="../../js/theme.js"></script>
|
||||
|
||||
<script>
|
||||
var shiftWindow = function() {
|
||||
scrollBy(0, -50)
|
||||
};
|
||||
|
||||
if (location.hash) shiftWindow();
|
||||
window.addEventListener("hashchange", shiftWindow);
|
||||
|
||||
$('.dropdown-menu').on('click touchstart', function(event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
// Dynamically force sidenav/dropdown to no higher than browser window
|
||||
$('.side-nav, .dropdown-menu').css('max-height', window.innerHeight - 130);
|
||||
|
||||
$(function() {
|
||||
$(window).resize(function() {
|
||||
$('.side-nav, .dropdown-menu').css('max-height', window.innerHeight - 130);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -435,7 +435,7 @@ class ProfileDetail(APIView):
|
|||
|
||||
<h1>Profile - {{ profile.name }}</h1>
|
||||
|
||||
<form action="{% url 'profile-detail' pk=profile.pk '%}" method="POST">
|
||||
<form action="{% url 'profile-detail' pk=profile.pk %}" method="POST">
|
||||
{% csrf_token %}
|
||||
{% render_form serializer %}
|
||||
<input type="submit" value="Save">
|
||||
|
|
|
@ -418,6 +418,27 @@
|
|||
</code></pre>
|
||||
<hr />
|
||||
<h2 id="33x-series"><a class="toclink" href="#33x-series">3.3.x series</a></h2>
|
||||
<h3 id="332"><a class="toclink" href="#332">3.3.2</a></h3>
|
||||
<p><strong>Date</strong>: <a href="https://github.com/tomchristie/django-rest-framework/issues?q=milestone%3A%223.3.2+Release%22">14th December 2015</a>.</p>
|
||||
<ul>
|
||||
<li><code>ListField</code> enforces input is a list. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3513">#3513</a>)</li>
|
||||
<li>Fix regression hiding raw data form. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3600">#3600</a>, <a href="https://github.com/tomchristie/django-rest-framework/issues/3578">#3578</a>)</li>
|
||||
<li>Fix Python 3.5 compatibility. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3534">#3534</a>, <a href="https://github.com/tomchristie/django-rest-framework/issues/3626">#3626</a>)</li>
|
||||
<li>Allow setting a custom Django Paginator in <code>pagination.PageNumberPagination</code>. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3631">#3631</a>, <a href="https://github.com/tomchristie/django-rest-framework/issues/3684">#3684</a>)</li>
|
||||
<li>Fix relational fields without <code>to_fields</code> attribute. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3635">#3635</a>, <a href="https://github.com/tomchristie/django-rest-framework/issues/3634">#3634</a>)</li>
|
||||
<li>Fix <code>template.render</code> deprecation warnings for Django 1.9. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3654">#3654</a>)</li>
|
||||
<li>Sort response headers in browsable API renderer. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3655">#3655</a>)</li>
|
||||
<li>Use related_objects api for Django 1.9+. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3656">#3656</a>, <a href="https://github.com/tomchristie/django-rest-framework/issues/3252">#3252</a>)</li>
|
||||
<li>Add confirm modal when deleting. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3228">#3228</a>, <a href="https://github.com/tomchristie/django-rest-framework/issues/3662">#3662</a>)</li>
|
||||
<li>Reveal previously hidden AttributeErrors and TypeErrors while calling has_[object_]permissions. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3668">#3668</a>)</li>
|
||||
<li>Make DRF compatible with multi template engine in Django 1.8. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3672">#3672</a>)</li>
|
||||
<li>Update <code>NestedBoundField</code> to also handle empty string when rendering its form. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3677">#3677</a>)</li>
|
||||
<li>Fix UUID validation to properly catch invalid input types. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3687">#3687</a>, <a href="https://github.com/tomchristie/django-rest-framework/issues/3679">#3679</a>)</li>
|
||||
<li>Fix caching issues. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3628">#3628</a>, <a href="https://github.com/tomchristie/django-rest-framework/issues/3701">#3701</a>)</li>
|
||||
<li>Fix Admin and API browser for views without a filter_class. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3705">#3705</a>, <a href="https://github.com/tomchristie/django-rest-framework/issues/3596">#3596</a>, <a href="https://github.com/tomchristie/django-rest-framework/issues/3597">#3597</a>)</li>
|
||||
<li>Add app_name to rest_framework.urls. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3714">#3714</a>)</li>
|
||||
<li>Improve authtoken's views to support url versioning. (<a href="https://github.com/tomchristie/django-rest-framework/issues/3718">#3718</a>, <a href="https://github.com/tomchristie/django-rest-framework/issues/3723">#3723</a>)</li>
|
||||
</ul>
|
||||
<h3 id="331"><a class="toclink" href="#331">3.3.1</a></h3>
|
||||
<p><strong>Date</strong>: <a href="https://github.com/tomchristie/django-rest-framework/issues?q=milestone%3A%223.3.1+Release%22">4th November 2015</a>.</p>
|
||||
<ul>
|
||||
|
@ -688,6 +709,8 @@
|
|||
<!-- 3.3.0 -->
|
||||
|
||||
<!-- 3.3.1 -->
|
||||
|
||||
<!-- 3.3.2 -->
|
||||
|
||||
|
||||
</div> <!--/span-->
|
||||
|
|
|
@ -506,7 +506,7 @@ url(r'^users/(?P<pk>[0-9]+)/$', views.UserDetail.as_view()),
|
|||
namespace='rest_framework')),
|
||||
]
|
||||
</code></pre>
|
||||
<p>The <code>r'^api-auth/'</code> part of pattern can actually be whatever URL you want to use. The only restriction is that the included urls must use the <code>'rest_framework'</code> namespace.</p>
|
||||
<p>The <code>r'^api-auth/'</code> part of pattern can actually be whatever URL you want to use. The only restriction is that the included urls must use the <code>'rest_framework'</code> namespace. In Django 1.9+, REST framework will set the namespace, so you may leave it out.</p>
|
||||
<p>Now if you open up the browser again and refresh the page you'll see a 'Login' link in the top right of the page. If you log in as one of the users you created earlier, you'll be able to create code snippets again.</p>
|
||||
<p>Once you've created a few code snippets, navigate to the '/users/' endpoint, and notice that the representation includes a list of the snippet pks that are associated with each user, in each user's 'snippets' field.</p>
|
||||
<h2 id="object-level-permissions"><a class="toclink" href="#object-level-permissions">Object level permissions</a></h2>
|
||||
|
|
Loading…
Reference in New Issue
Block a user