diff options
45 files changed, 100 insertions, 57 deletions
| diff --git a/api-guide/authentication.html b/api-guide/authentication.html index 9b11fbe5..c05b60aa 100644 --- a/api-guide/authentication.html +++ b/api-guide/authentication.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/content-negotiation.html b/api-guide/content-negotiation.html index de57feff..863c0720 100644 --- a/api-guide/content-negotiation.html +++ b/api-guide/content-negotiation.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/exceptions.html b/api-guide/exceptions.html index b06b3ebe..0f6a1f0b 100644 --- a/api-guide/exceptions.html +++ b/api-guide/exceptions.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/fields.html b/api-guide/fields.html index 4ca9b1fb..91852e00 100644 --- a/api-guide/fields.html +++ b/api-guide/fields.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/filtering.html b/api-guide/filtering.html index 5f401df9..cef40e9e 100644 --- a/api-guide/filtering.html +++ b/api-guide/filtering.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/format-suffixes.html b/api-guide/format-suffixes.html index 7bbedae8..7a551743 100644 --- a/api-guide/format-suffixes.html +++ b/api-guide/format-suffixes.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/generic-views.html b/api-guide/generic-views.html index be6e19f1..9ae8efff 100644 --- a/api-guide/generic-views.html +++ b/api-guide/generic-views.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> @@ -279,10 +280,6 @@ class UserList(generics.ListCreateAPIView):  <li><code>lookup_field</code> - The model field that should be used to for performing object lookup of individual model instances.  Defaults to <code>'pk'</code>.  Note that when using hyperlinked APIs you'll need to ensure that <em>both</em> the API views <em>and</em> the serializer classes set the lookup fields if you need to use a custom value.</li>  <li><code>lookup_url_kwarg</code> - The URL keyword argument that should be used for object lookup.  The URL conf should include a keyword argument corresponding to this value.  If unset this defaults to using the same value as <code>lookup_field</code>.</li>  </ul> -<p><strong>Shortcuts</strong>:</p> -<ul> -<li><code>model</code> - This shortcut may be used instead of setting either (or both) of the <code>queryset</code>/<code>serializer_class</code> attributes, although using the explicit style is generally preferred.  If used instead of <code>serializer_class</code>, then <code>DEFAULT_MODEL_SERIALIZER_CLASS</code> setting will determine the base serializer class.  Note that <code>model</code> is only ever used for generating a default queryset or serializer class - the <code>queryset</code> and <code>serializer_class</code> attributes are always preferred if provided.</li> -</ul>  <p><strong>Pagination</strong>:</p>  <p>The following attributes are used to control pagination when used with list views.</p>  <ul> @@ -295,6 +292,10 @@ class UserList(generics.ListCreateAPIView):  <ul>  <li><code>filter_backends</code> - A list of filter backend classes that should be used for filtering the queryset.  Defaults to the same value as the <code>DEFAULT_FILTER_BACKENDS</code> setting.</li>  </ul> +<p><strong>Deprecated attributes</strong>:</p> +<ul> +<li><code>model</code> - This shortcut may be used instead of setting either (or both) of the <code>queryset</code>/<code>serializer_class</code> attributes. The explicit style is preferred over the <code>.model</code> shortcut, and usage of this attribute is now deprecated.</li> +</ul>  <h3 id="methods">Methods</h3>  <p><strong>Base methods</strong>:</p>  <h4 id="get_querysetself"><code>get_queryset(self)</code></h4> diff --git a/api-guide/pagination.html b/api-guide/pagination.html index c462a7a6..3f80ea19 100644 --- a/api-guide/pagination.html +++ b/api-guide/pagination.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/parsers.html b/api-guide/parsers.html index 7edce817..52ee597a 100644 --- a/api-guide/parsers.html +++ b/api-guide/parsers.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/permissions.html b/api-guide/permissions.html index afc18e56..202da323 100644 --- a/api-guide/permissions.html +++ b/api-guide/permissions.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> @@ -292,7 +293,7 @@ def example_view(request, format=None):  <p>The <code>IsAuthenticatedOrReadOnly</code> will allow authenticated users to perform any request.  Requests for unauthorised users will only be permitted if the request method is one of the "safe" methods; <code>GET</code>, <code>HEAD</code> or <code>OPTIONS</code>.</p>  <p>This permission is suitable if you want to your API to allow read permissions to anonymous users, and only allow write permissions to authenticated users.</p>  <h2 id="djangomodelpermissions">DjangoModelPermissions</h2> -<p>This permission class ties into Django's standard <code>django.contrib.auth</code> <a href="https://docs.djangoproject.com/en/dev/topics/auth/customizing/#custom-permissions">model permissions</a>.  When applied to a view that has a <code>.model</code> property, authorization will only be granted if the user <em>is authenticated</em> and has the <em>relevant model permissions</em> assigned.</p> +<p>This permission class ties into Django's standard <code>django.contrib.auth</code> <a href="https://docs.djangoproject.com/en/dev/topics/auth/customizing/#custom-permissions">model permissions</a>.  This permission must only be applied to views that has a <code>.queryset</code> property set. Authorization will only be granted if the user <em>is authenticated</em> and has the <em>relevant model permissions</em> assigned.</p>  <ul>  <li><code>POST</code> requests require the user to have the <code>add</code> permission on the model.</li>  <li><code>PUT</code> and <code>PATCH</code> requests require the user to have the <code>change</code> permission on the model.</li> @@ -300,11 +301,15 @@ def example_view(request, format=None):  </ul>  <p>The default behaviour can also be overridden to support custom model permissions.  For example, you might want to include a <code>view</code> model permission for <code>GET</code> requests.</p>  <p>To use custom model permissions, override <code>DjangoModelPermissions</code> and set the <code>.perms_map</code> property.  Refer to the source code for details.</p> +<h4 id="using-with-views-that-do-not-include-a-queryset-attribute">Using with views that do not include a <code>queryset</code> attribute.</h4> +<p>If you're using this permission with a view that uses an overridden <code>get_queryset()</code> method there may not be a <code>queryset</code> attribute on the view. In this case we suggest also marking the view with a sential queryset, so that this class can determine the required permissions. For example:</p> +<pre class="prettyprint lang-py"><code>queryset = User.objects.none()  # Required for DjangoModelPermissions +</code></pre>  <h2 id="djangomodelpermissionsoranonreadonly">DjangoModelPermissionsOrAnonReadOnly</h2>  <p>Similar to <code>DjangoModelPermissions</code>, but also allows unauthenticated users to have read-only access to the API.</p>  <h2 id="djangoobjectpermissions">DjangoObjectPermissions</h2>  <p>This permission class ties into Django's standard <a href="https://docs.djangoproject.com/en/dev/topics/auth/customizing/#handling-object-permissions">object permissions framework</a> that allows per-object permissions on models.  In order to use this permission class, you'll also need to add a permission backend that supports object-level permissions, such as <a href="https://github.com/lukaszb/django-guardian">django-guardian</a>.</p> -<p>When applied to a view that has a <code>.model</code> property, authorization will only be granted if the user <em>is authenticated</em> and has the <em>relevant per-object permissions</em> and <em>relevant model permissions</em> assigned.</p> +<p>As with <code>DjangoModelPermissions</code>, this permission must only be applied to views that have a <code>.queryset</code> property. Authorization will only be granted if the user <em>is authenticated</em> and has the <em>relevant per-object permissions</em> and <em>relevant model permissions</em> assigned.</p>  <ul>  <li><code>POST</code> requests require the user to have the <code>add</code> permission on the model instance.</li>  <li><code>PUT</code> and <code>PATCH</code> requests require the user to have the <code>change</code> permission on the model instance.</li> diff --git a/api-guide/relations.html b/api-guide/relations.html index faa7a229..b4da5ccd 100644 --- a/api-guide/relations.html +++ b/api-guide/relations.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/renderers.html b/api-guide/renderers.html index cf22546f..5678f5e0 100644 --- a/api-guide/renderers.html +++ b/api-guide/renderers.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/requests.html b/api-guide/requests.html index 6c72463d..5b2e7286 100644 --- a/api-guide/requests.html +++ b/api-guide/requests.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/responses.html b/api-guide/responses.html index 0998c35d..19d7ddff 100644 --- a/api-guide/responses.html +++ b/api-guide/responses.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/reverse.html b/api-guide/reverse.html index 9ac1f216..e6f687fa 100644 --- a/api-guide/reverse.html +++ b/api-guide/reverse.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/routers.html b/api-guide/routers.html index 77c6e585..b5df3b0f 100644 --- a/api-guide/routers.html +++ b/api-guide/routers.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> @@ -242,8 +243,8 @@ urlpatterns = router.urls  </ul>  <hr />  <p><strong>Note</strong>: The <code>base_name</code> argument is used to specify the initial part of the view name pattern.  In the example above, that's the <code>user</code> or <code>account</code> part.</p> -<p>Typically you won't <em>need</em> to specify the <code>base-name</code> argument, but if you have a viewset where you've defined a custom <code>get_queryset</code> method, then the viewset may not have any <code>.model</code> or <code>.queryset</code> attribute set.  If you try to register that viewset you'll see an error like this:</p> -<pre class="prettyprint lang-py"><code>'base_name' argument not specified, and could not automatically determine the name from the viewset, as it does not have a '.model' or '.queryset' attribute. +<p>Typically you won't <em>need</em> to specify the <code>base-name</code> argument, but if you have a viewset where you've defined a custom <code>get_queryset</code> method, then the viewset may not have a <code>.queryset</code> attribute set.  If you try to register that viewset you'll see an error like this:</p> +<pre class="prettyprint lang-py"><code>'base_name' argument not specified, and could not automatically determine the name from the viewset, as it does not have a '.queryset' attribute.  </code></pre>  <p>This means you'll need to explicitly set the <code>base_name</code> argument when registering the viewset, as it could not be automatically determined from the model name.</p>  <hr /> diff --git a/api-guide/serializers.html b/api-guide/serializers.html index f90aff16..3a4f9875 100644 --- a/api-guide/serializers.html +++ b/api-guide/serializers.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/settings.html b/api-guide/settings.html index 59823263..4b476851 100644 --- a/api-guide/settings.html +++ b/api-guide/settings.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> @@ -275,9 +276,6 @@ print api_settings.DEFAULT_AUTHENTICATION_CLASSES  <hr />  <h2 id="generic-view-settings">Generic view settings</h2>  <p><em>The following settings control the behavior of the generic class based views.</em></p> -<h4 id="default_model_serializer_class">DEFAULT_MODEL_SERIALIZER_CLASS</h4> -<p>A class that determines the default type of model serializer that should be used by a generic view if <code>model</code> is specified, but <code>serializer_class</code> is not provided.</p> -<p>Default: <code>'rest_framework.serializers.ModelSerializer'</code></p>  <h4 id="default_pagination_serializer_class">DEFAULT_PAGINATION_SERIALIZER_CLASS</h4>  <p>A class the determines the default serialization style for paginated responses.</p>  <p>Default: <code>rest_framework.pagination.PaginationSerializer</code></p> diff --git a/api-guide/status-codes.html b/api-guide/status-codes.html index 070d004f..4df4bc0f 100644 --- a/api-guide/status-codes.html +++ b/api-guide/status-codes.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/testing.html b/api-guide/testing.html index c30b1e95..4f23c943 100644 --- a/api-guide/testing.html +++ b/api-guide/testing.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/throttling.html b/api-guide/throttling.html index 49642481..71db0319 100644 --- a/api-guide/throttling.html +++ b/api-guide/throttling.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/views.html b/api-guide/views.html index 934c0aae..0118412b 100644 --- a/api-guide/views.html +++ b/api-guide/views.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/api-guide/viewsets.html b/api-guide/viewsets.html index 454d7d82..2e5915a9 100644 --- a/api-guide/viewsets.html +++ b/api-guide/viewsets.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> @@ -289,14 +290,9 @@ pip install django-filter  # Filtering support  <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>  <h2 id="example">Example</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 users and groups.</p> +<p>We'll create a read-write API for accessing information on the users of our project.</p>  <p>Any global settings for a REST framework API are kept in a single configuration dictionary named <code>REST_FRAMEWORK</code>.  Start off by adding the following to your <code>settings.py</code> module:</p>  <pre class="prettyprint lang-py"><code>REST_FRAMEWORK = { -    # Use hyperlinked styles by default. -    # Only used if the `serializer_class` attribute is not set on a view. -    'DEFAULT_MODEL_SERIALIZER_CLASS': -        'rest_framework.serializers.HyperlinkedModelSerializer', -      # Use Django's standard `django.contrib.auth` permissions,      # or allow read-only access for unauthenticated users.      'DEFAULT_PERMISSION_CLASSES': [ @@ -307,33 +303,35 @@ 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 class="prettyprint lang-py"><code>from django.conf.urls import url, patterns, include -from django.contrib.auth.models import User, Group -from rest_framework import viewsets, routers +<pre class="prettyprint lang-py"><code>from django.conf.urls import url, include +from django.contrib.auth.models import User +from rest_framework import routers, serializers, viewsets + +# Serializers define the API representation. +class UserSerializer(serializers.HyperlinkedModelSerializer): +    class Meta: +        model = User +        fields = ('url', 'username', 'email', 'is_staff')  # ViewSets define the view behavior.  class UserViewSet(viewsets.ModelViewSet): -    model = User - -class GroupViewSet(viewsets.ModelViewSet): -    model = Group - +    queryset = User.objects.all() +    serializer_class = UserSerializer  # Routers provide an easy way of automatically determining the URL conf.  router = routers.DefaultRouter()  router.register(r'users', UserViewSet) -router.register(r'groups', GroupViewSet) -  # Wire up our API using automatic URL routing.  # Additionally, we include login URLs for the browseable API. -urlpatterns = patterns('', +urlpatterns = [      url(r'^', include(router.urls)),      url(r'^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>  <h2 id="quickstart">Quickstart</h2> -<p>Can't wait to get started?  The <a href="tutorial/quickstart">quickstart guide</a> is the fastest way to get up and running, and building APIs with REST framework.</p> +<p>Can't wait to get started? The <a href="tutorial/quickstart">quickstart guide</a> is the fastest way to get up and running, and building APIs with REST framework.</p>  <h2 id="tutorial">Tutorial</h2>  <p>The tutorial will walk you through the building blocks that make up REST framework.   It'll take a little while to get through, but it'll give you a comprehensive understanding of how everything fits together, and is highly recommended reading.</p>  <ul> @@ -384,6 +382,7 @@ urlpatterns = patterns('',  <li><a href="topics/rest-framework-2-announcement">2.0 Announcement</a></li>  <li><a href="topics/2.2-announcement">2.2 Announcement</a></li>  <li><a href="topics/2.3-announcement">2.3 Announcement</a></li> +<li><a href="topics/2.4-announcement">2.4 Announcement</a></li>  <li><a href="topics/kickstarter-announcement">Kickstarter Announcement</a></li>  <li><a href="topics/release-notes">Release Notes</a></li>  <li><a href="topics/credits">Credits</a></li> diff --git a/topics/2.2-announcement.html b/topics/2.2-announcement.html index d78540e9..158c58d4 100644 --- a/topics/2.2-announcement.html +++ b/topics/2.2-announcement.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/topics/2.3-announcement.html b/topics/2.3-announcement.html index be0f328c..364483d8 100644 --- a/topics/2.3-announcement.html +++ b/topics/2.3-announcement.html @@ -57,7 +57,7 @@ a.fusion-poweredby {        <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 " href="../topics/release-notes">Next <i class="icon-arrow-right icon-white"></i></a> +            <a class="repo-link btn btn-inverse btn-small " href="../topics/2.4-announcement">Next <i class="icon-arrow-right icon-white"></i></a>              <a class="repo-link btn btn-inverse btn-small " href="../topics/2.2-announcement"><i class="icon-arrow-left icon-white"></i> Previous</a>              <a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>            <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/topics/2.4-accouncement.html b/topics/2.4-accouncement.html index 0b4df1a8..7526010f 100644 --- a/topics/2.4-accouncement.html +++ b/topics/2.4-accouncement.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> @@ -187,6 +188,7 @@ a.fusion-poweredby {                  <li class="main"><a href="#rest-framework-24-announcement">REST framework 2.4 announcement</a></li>  <li><a href="#version-requirements">Version requirements</a></li>  <li><a href="#django-17-support">Django 1.7 support</a></li> +<li><a href="#deprecation-of-`model`-view-attribute">Deprecation of `.model` view attribute</a></li>  <li><a href="#updated-test-runner">Updated test runner</a></li>  <li><a href="#improved-viewset-routing">Improved viewset routing</a></li>  <li><a href="#throttle-behavior">Throttle behavior</a></li> @@ -213,6 +215,12 @@ The lowest supported version of Django is now 1.4.2.</p>  <h2 id="django-17-support">Django 1.7 support</h2>  <p>The optional authtoken application now includes support for <em>both</em> Django 1.7 schema migrations, <em>and</em> for old-style <code>south</code> migrations.</p>  <p><strong>If you are using authtoken, and you want to continue using <code>south</code>, you must upgrade your <code>south</code> package to version 1.0.</strong></p> +<h2 id="deprecation-of-model-view-attribute">Deprecation of <code>.model</code> view attribute</h2> +<p>The <code>.model</code> attribute on view classes is an optional shortcut for either or both of <code>.serializer_class</code> and <code>.queryset</code>. It's usage results in more implicit, less obvious behavior.</p> +<p>The documentation has previously stated that usage of the more explicit style is prefered, and we're now taking that one step further and deprecating the usage of the <code>.model</code> shortcut.</p> +<p>Doing so will mean that there are cases of API code where you'll now need to include a serializer class where you previously were just using the <code>.model</code> shortcut. However we firmly believe that it is the right trade-off to make.</p> +<p>Removing the shortcut takes away an unneccessary layer of abstraction, and makes your codebase more explicit without any significant extra complexity. It also results in better consistency, as there's now only one way to set the serializer class and queryset attributes for the view, instead of two.</p> +<p>The <code>DEFAULT_MODEL_SERIALIZER_CLASS</code> API setting is now also deprecated.</p>  <h2 id="updated-test-runner">Updated test runner</h2>  <p>We now have a new test runner for developing against the project,, that uses the excellent <a href="http://pytest.org">py.test</a> library.</p>  <p>To use it make sure you have first installed the test requirements.</p> diff --git a/topics/ajax-csrf-cors.html b/topics/ajax-csrf-cors.html index e62bca74..fab49dc5 100644 --- a/topics/ajax-csrf-cors.html +++ b/topics/ajax-csrf-cors.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/topics/browsable-api.html b/topics/browsable-api.html index 82ea30ef..d0a575ca 100644 --- a/topics/browsable-api.html +++ b/topics/browsable-api.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/topics/browser-enhancements.html b/topics/browser-enhancements.html index dff2181b..7322ebf4 100644 --- a/topics/browser-enhancements.html +++ b/topics/browser-enhancements.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/topics/contributing.html b/topics/contributing.html index 4fc3efec..2ef70c81 100644 --- a/topics/contributing.html +++ b/topics/contributing.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/topics/credits.html b/topics/credits.html index ac8c7a39..ce180992 100644 --- a/topics/credits.html +++ b/topics/credits.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/topics/documenting-your-api.html b/topics/documenting-your-api.html index 0a1c7997..b65dc393 100644 --- a/topics/documenting-your-api.html +++ b/topics/documenting-your-api.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/topics/kickstarter-announcement.html b/topics/kickstarter-announcement.html index 9ad62616..5dbb1ac2 100644 --- a/topics/kickstarter-announcement.html +++ b/topics/kickstarter-announcement.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/topics/release-notes.html b/topics/release-notes.html index 0a09205d..af1de67f 100644 --- a/topics/release-notes.html +++ b/topics/release-notes.html @@ -58,7 +58,7 @@ a.fusion-poweredby {          <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 " href="../topics/credits">Next <i class="icon-arrow-right icon-white"></i></a> -            <a class="repo-link btn btn-inverse btn-small " href="../topics/2.3-announcement"><i class="icon-arrow-left icon-white"></i> Previous</a> +            <a class="repo-link btn btn-inverse btn-small " href="../topics/2.4-announcement"><i class="icon-arrow-left icon-white"></i> Previous</a>              <a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>            <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">              <span class="icon-bar"></span> @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> @@ -241,11 +242,13 @@ a.fusion-poweredby {  <hr />  <h2 id="24x-series">2.4.x series</h2>  <h3 id="240">2.4.0</h3> +<p><strong>Date</strong>: 29th August 2014</p>  <p><strong>Django version requirements</strong>: The lowest supported version of Django is now 1.4.2.</p>  <p><strong>South version requirements</strong>: This note applies to any users using the optional <code>authtoken</code> application, which includes an associated database migration. You must now <em>either</em> upgrade your <code>south</code> package to version 1.0, <em>or</em> instead use the built-in migration support available with Django 1.7.</p>  <ul>  <li>Added compatibility with Django 1.7's database migration support.</li>  <li>New test runner, using <code>py.test</code>.</li> +<li>Deprecated <code>.model</code> view attribute in favor of explicit <code>.queryset</code> and <code>.serializer_class</code> attributes. The <code>DEFAULT_MODEL_SERIALIZER_CLASS</code> setting is also deprecated.</li>  <li><code>@detail_route</code> and <code>@list_route</code> decorators replace <code>@action</code> and <code>@link</code>.</li>  <li>Support customizable view name and description functions, using the <code>VIEW_NAME_FUNCTION</code> and <code>VIEW_DESCRIPTION_FUNCTION</code> settings.</li>  <li>Added <code>NUM_PROXIES</code> setting for smarter client IP identification.</li> diff --git a/topics/rest-framework-2-announcement.html b/topics/rest-framework-2-announcement.html index 37213e64..30995d21 100644 --- a/topics/rest-framework-2-announcement.html +++ b/topics/rest-framework-2-announcement.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/topics/rest-hypermedia-hateoas.html b/topics/rest-hypermedia-hateoas.html index 1ed3d6ea..dd69e563 100644 --- a/topics/rest-hypermedia-hateoas.html +++ b/topics/rest-hypermedia-hateoas.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/topics/writable-nested-serializers.html b/topics/writable-nested-serializers.html index 11aa487c..ff997580 100644 --- a/topics/writable-nested-serializers.html +++ b/topics/writable-nested-serializers.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/tutorial/1-serialization.html b/tutorial/1-serialization.html index 53401303..f5eff13c 100644 --- a/tutorial/1-serialization.html +++ b/tutorial/1-serialization.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/tutorial/2-requests-and-responses.html b/tutorial/2-requests-and-responses.html index 7dd66190..dd86ca9e 100644 --- a/tutorial/2-requests-and-responses.html +++ b/tutorial/2-requests-and-responses.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/tutorial/3-class-based-views.html b/tutorial/3-class-based-views.html index b20becf3..ce512b13 100644 --- a/tutorial/3-class-based-views.html +++ b/tutorial/3-class-based-views.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/tutorial/4-authentication-and-permissions.html b/tutorial/4-authentication-and-permissions.html index 01d84818..aaba32d8 100644 --- a/tutorial/4-authentication-and-permissions.html +++ b/tutorial/4-authentication-and-permissions.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/tutorial/5-relationships-and-hyperlinked-apis.html b/tutorial/5-relationships-and-hyperlinked-apis.html index 0c274c05..4695e412 100644 --- a/tutorial/5-relationships-and-hyperlinked-apis.html +++ b/tutorial/5-relationships-and-hyperlinked-apis.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/tutorial/6-viewsets-and-routers.html b/tutorial/6-viewsets-and-routers.html index d7efceb4..6fef6a31 100644 --- a/tutorial/6-viewsets-and-routers.html +++ b/tutorial/6-viewsets-and-routers.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> diff --git a/tutorial/quickstart.html b/tutorial/quickstart.html index 47107d0e..42588e5d 100644 --- a/tutorial/quickstart.html +++ b/tutorial/quickstart.html @@ -121,6 +121,7 @@ a.fusion-poweredby {                    <li><a href="http://www.django-rest-framework.org/topics/rest-framework-2-announcement">2.0 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.2-announcement">2.2 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/2.3-announcement">2.3 Announcement</a></li> +                  <li><a href="http://www.django-rest-framework.org/topics/2.4-announcement">2.4 Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/kickstarter-announcement">Kickstarter Announcement</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/release-notes">Release Notes</a></li>                    <li><a href="http://www.django-rest-framework.org/topics/credits">Credits</a></li> @@ -217,30 +218,19 @@ source env/bin/activate  # On Windows use `env\Scripts\activate`  pip install django  pip install djangorestframework -# Set up a new project -django-admin.py startproject tutorial - -# Create a new app -python manage.py startapp quickstart -</code></pre> -<p>Next you'll need to get a database set up and synced.  If you just want to use SQLite for now, then you'll want to edit your <code>tutorial/settings.py</code> module to include something like this:</p> -<pre class="prettyprint lang-py"><code>DATABASES = { -    'default': { -        'ENGINE': 'django.db.backends.sqlite3', -        'NAME': 'database.sql', -        'USER': '', -        'PASSWORD': '', -        'HOST': '', -        'PORT': '' -    } -} +# Set up a new project with a single application +django-admin.py startproject tutorial . +cd tutorial +django-admin.py startapp quickstart +cd ..  </code></pre> -<p>The run <code>syncdb</code> like so:</p> +<p>Now sync your database for the first time:</p>  <pre class="prettyprint lang-py"><code>python manage.py syncdb  </code></pre> +<p>Make sure to create an initial user named <code>admin</code> with a password of <code>password</code>. We'll authenticate as that user later in our example.</p>  <p>Once you've set up a database and got everything synced and ready to go, open up the app's directory and we'll get coding...</p>  <h2 id="serializers">Serializers</h2> -<p>First up we're going to define some serializers in <code>quickstart/serializers.py</code> that we'll use for our data representations.</p> +<p>First up we're going to define some serializers. Let's create a new module named <code>tutorial/quickstart/serializers.py</code> that we'll use for our data representations.</p>  <pre class="prettyprint lang-py"><code>from django.contrib.auth.models import User, Group  from rest_framework import serializers @@ -258,10 +248,10 @@ class GroupSerializer(serializers.HyperlinkedModelSerializer):  </code></pre>  <p>Notice that we're using hyperlinked relations in this case, with <code>HyperlinkedModelSerializer</code>.  You can also use primary key and various other relationships, but hyperlinking is good RESTful design.</p>  <h2 id="views">Views</h2> -<p>Right, we'd better write some views then.  Open <code>quickstart/views.py</code> and get typing.</p> +<p>Right, we'd better write some views then.  Open <code>tutorial/quickstart/views.py</code> and get typing.</p>  <pre class="prettyprint lang-py"><code>from django.contrib.auth.models import User, Group  from rest_framework import viewsets -from quickstart.serializers import UserSerializer, GroupSerializer +from tutorial.quickstart.serializers import UserSerializer, GroupSerializer  class UserViewSet(viewsets.ModelViewSet): @@ -285,9 +275,9 @@ class GroupViewSet(viewsets.ModelViewSet):  <p>For trivial cases you can simply set a <code>model</code> attribute on the <code>ViewSet</code> class and the serializer and queryset will be automatically generated for you.  Setting the <code>queryset</code> and/or <code>serializer_class</code> attributes gives you more explicit control of the API behaviour, and is the recommended style for most applications.</p>  <h2 id="urls">URLs</h2>  <p>Okay, now let's wire up the API URLs.  On to <code>tutorial/urls.py</code>...</p> -<pre class="prettyprint lang-py"><code>from django.conf.urls import patterns, url, include +<pre class="prettyprint lang-py"><code>from django.conf.urls import url, include  from rest_framework import routers -from quickstart import views +from tutorial.quickstart import views  router = routers.DefaultRouter()  router.register(r'users', views.UserViewSet) @@ -295,10 +285,10 @@ router.register(r'groups', views.GroupViewSet)  # Wire up our API using automatic URL routing.  # Additionally, we include login URLs for the browseable API. -urlpatterns = patterns('', +urlpatterns = [      url(r'^', include(router.urls)),      url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) -) +]  </code></pre>  <p>Because we're using viewsets instead of views, we can automatically generate the URL conf for our API, by simply registering the viewsets with a router class.</p>  <p>Again, if we need more control over the API URLs we can simply drop down to using regular class based views, and writing the URL conf explicitly.</p> @@ -345,6 +335,7 @@ REST_FRAMEWORK = {  </code></pre>  <p>Or directly through the browser...</p>  <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>            </div><!--/span--> | 
