You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p><strong>Note</strong>: This is the documentation for the <strong>version 3.0</strong> of REST framework. Documentation for <ahref="http://tomchristie.github.io/rest-framework-2-docs/">version 2.4</a> is also available.</p>
581
-
<hr/>
582
-
<h1id="serializer-fields">Serializer fields</h1>
579
+
<h1id="serializer-fields">Serializer fields</h1>
583
580
<blockquote>
584
581
<p>Each field in a Form class is responsible not only for validating data, but also for "cleaning" it — normalizing it to a consistent format.</p>
<p><strong>Note</strong>: This is the documentation for the <strong>version 3.0</strong> of REST framework. Documentation for <ahref="http://tomchristie.github.io/rest-framework-2-docs/">version 2.4</a> is also available.</p>
501
-
<hr/>
502
-
<h1id="generic-views">Generic views</h1>
499
+
<h1id="generic-views">Generic views</h1>
503
500
<blockquote>
504
501
<p>Django’s generic views... were developed as a shortcut for common usage patterns... They take certain common idioms and patterns found in view development and abstract them so that you can quickly write common views of data without having to repeat yourself.</p>
<p><strong>Note</strong>: This is the documentation for the <strong>version 3.0</strong> of REST framework. Documentation for <ahref="http://tomchristie.github.io/rest-framework-2-docs/">version 2.4</a> is also available.</p>
393
-
<hr/>
394
-
<h1id="metadata">Metadata</h1>
391
+
<h1id="metadata">Metadata</h1>
395
392
<blockquote>
396
393
<p>[The <code>OPTIONS</code>] method allows a client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval.</p>
<p>To enable the <code>PageNumberPagination</code> style globally, use the following configuration, modifying the <code>DEFAULT_PAGE_SIZE</code> as desired:</p>
505
+
<p>To enable the <code>PageNumberPagination</code> style globally, use the following configuration, modifying the <code>PAGE_SIZE</code> as desired:</p>
<p>On <code>GenericAPIView</code> subclasses you may also set the <code>pagination_class</code> attribute to select <code>PageNumberPagination</code> on a per-view basis.</p>
512
512
<h4id="configuration">Configuration</h4>
513
513
<p>The <code>PageNumberPagination</code> class includes a number of attributes that may be overridden to modify the pagination style.</p>
514
514
<p>To set these attributes you should override the <code>PageNumberPagination</code> class, and then enable your custom pagination class as above.</p>
515
515
<ul>
516
-
<li><code>page_size</code> - A numeric value indicating the page size. If set, this overrides the <code>DEFAULT_PAGE_SIZE</code> setting. Defaults to the same value as the <code>DEFAULT_PAGE_SIZE</code> settings key.</li>
516
+
<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>
517
517
<li><code>page_query_param</code> - A string value indicating the name of the query parameter to use for the pagination control.</li>
518
518
<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>
519
519
<li><code>max_page_size</code> - If set, this is a numeric value indicating the maximum allowable requested page size. This attribute is only valid if <code>page_size_query_param</code> is also set.</li>
<p>Optionally, you may also set a <code>DEFAULT_PAGE_SIZE</code> key. If the <code>DEFAULT_PAGE_SIZE</code> parameter is also used then the <code>limit</code> query parameter will be optional, and may be omitted by the client.</p>
547
+
<p>Optionally, you may also set a <code>PAGE_SIZE</code> key. If the <code>PAGE_SIZE</code> parameter is also used then the <code>limit</code> query parameter will be optional, and may be omitted by the client.</p>
548
548
<p>On <code>GenericAPIView</code> subclasses you may also set the <code>pagination_class</code> attribute to select <code>LimitOffsetPagination</code> on a per-view basis.</p>
549
549
<h4id="configuration_1">Configuration</h4>
550
550
<p>The <code>LimitOffsetPagination</code> class includes a number of attributes that may be overridden to modify the pagination style.</p>
551
551
<p>To set these attributes you should override the <code>LimitOffsetPagination</code> class, and then enable your custom pagination class as above.</p>
552
552
<ul>
553
-
<li><code>default_limit</code> - A numeric value indicating the limit to use if one is not provided by the client in a query parameter. Defaults to the same value as the <code>DEFAULT_PAGE_SIZE</code> settings key.</li>
553
+
<li><code>default_limit</code> - A numeric value indicating the limit to use if one is not provided by the client in a query parameter. Defaults to the same value as the <code>PAGE_SIZE</code> settings key.</li>
554
554
<li><code>limit_query_param</code> - A string value indicating the name of the "limit" query parameter. Defaults to <code>'limit'</code>.</li>
555
555
<li><code>offset_query_param</code> - A string value indicating the name of the "offset" query parameter. Defaults to <code>'offset'</code>.</li>
556
556
<li><code>max_limit</code> - If set this is a numeric value indicating the maximum allowable limit that may be requested by the client. Defaults to <code>None</code>.</li>
<li>Supports usage with very large datasets. With extremely large datasets pagination using offset-based pagination styles may become inefficient or unusable. Cursor based pagination schemes instead have fixed-time properties, and do not slow down as the dataset size increases.</li>
567
567
</ul>
568
568
<h4id="details-and-limitations">Details and limitations</h4>
569
-
<p>Proper use of cursor based pagination a little attention to detail. You'll need to think about what ordering you want the scheme to be applied against. The default is to order by <code>"-created"</code>. This assumes that <strong>there must be a 'created' timestamp field</strong> on the model instances, and will present a "timeline" style paginated view, with the most recently added items first.</p>
569
+
<p>Proper use of cursor based pagination requires a little attention to detail. You'll need to think about what ordering you want the scheme to be applied against. The default is to order by <code>"-created"</code>. This assumes that <strong>there must be a 'created' timestamp field</strong> on the model instances, and will present a "timeline" style paginated view, with the most recently added items first.</p>
570
570
<p>You can modify the ordering by overriding the <code>'ordering'</code> attribute on the pagination class, or by using the <code>OrderingFilter</code> filter class together with <code>CursorPagination</code>. When used with <code>OrderingFilter</code> you should strongly consider restricting the fields that the user may order by.</p>
571
571
<p>Proper usage of cursor pagination should have an ordering field that satisfies the following:</p>
572
572
<ul>
@@ -578,10 +578,10 @@ <h4 id="details-and-limitations">Details and limitations</h4>
578
578
<p>Using an ordering field that does not satisfy these constraints will generally still work, but you'll be loosing some of the benefits of cursor pagination.</p>
579
579
<p>For more technical details on the implementation we use for cursor pagination, the <ahref="http://cramer.io/2011/03/08/building-cursors-for-the-disqus-api/">"Building cursors for the Disqus API"</a> blog post gives a good overview of the basic approach.</p>
580
580
<h4id="setup_2">Setup</h4>
581
-
<p>To enable the <code>CursorPagination</code> style globally, use the following configuration, modifying the <code>DEFAULT_PAGE_SIZE</code> as desired:</p>
581
+
<p>To enable the <code>CursorPagination</code> style globally, use the following configuration, modifying the <code>PAGE_SIZE</code> as desired:</p>
<p>On <code>GenericAPIView</code> subclasses you may also set the <code>pagination_class</code> attribute to select <code>CursorPagination</code> on a per-view basis.</p>
<p><strong>Note</strong>: This is the documentation for the <strong>version 3.0</strong> of REST framework. Documentation for <ahref="http://tomchristie.github.io/rest-framework-2-docs/">version 2.4</a> is also available.</p>
<p><strong>Note</strong>: This is the documentation for the <strong>version 3.0</strong> of REST framework. Documentation for <ahref="http://tomchristie.github.io/rest-framework-2-docs/">version 2.4</a> is also available.</p>
465
-
<hr/>
466
-
<h1id="requests">Requests</h1>
463
+
<h1id="requests">Requests</h1>
467
464
<blockquote>
468
465
<p>If you're doing REST-based web service stuff ... you should ignore request.POST.</p>
<p><strong>Note</strong>: This is the documentation for the <strong>version 3.0</strong> of REST framework. Documentation for <ahref="http://tomchristie.github.io/rest-framework-2-docs/">version 2.4</a> is also available.</p>
557
-
<hr/>
558
-
<h1id="serializers">Serializers</h1>
555
+
<h1id="serializers">Serializers</h1>
559
556
<blockquote>
560
557
<p>Expanding the usefulness of the serializers is something that we would
561
558
like to address. However, it's not a trivial problem, and it
<p><strong>Note</strong>: This is the documentation for the <strong>version 3.0</strong> of REST framework. Documentation for <ahref="http://tomchristie.github.io/rest-framework-2-docs/">version 2.4</a> is also available.</p>
429
-
<hr/>
430
-
<h1id="validators">Validators</h1>
427
+
<h1id="validators">Validators</h1>
431
428
<blockquote>
432
429
<p>Validators can be useful for re-using validation logic between different types of fields.</p>
<p><strong>Note</strong>: This is the documentation for the <strong>version 3.0</strong> of REST framework. Documentation for <ahref="http://tomchristie.github.io/rest-framework-2-docs/">version 2.4</a> is also available.</p>
465
-
<p>For more details see the <ahref="topics/3.0-announcement/">3.0 release notes</a>.</p>
464
+
<p><strong>Note</strong>: This is the documentation for the <strong>version 3.1</strong> of REST framework. Documentation for <ahref="http://tomchristie.github.io/rest-framework-2-docs/">version 2.4</a> is also available.</p>
465
+
<p>For more details see the <ahref="topics/3.1-announcement/">3.1 release notes</a>.</p>
0 commit comments