aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/views.md
diff options
context:
space:
mode:
authorTom Christie2012-10-27 18:39:17 +0100
committerTom Christie2012-10-27 18:39:17 +0100
commitcef379db065711bd2f1b0805d28a56f7a80cef37 (patch)
tree223aa2da7b83ea90946400f22bb5fe6e85c1cbd9 /docs/api-guide/views.md
parentec1429ffc8079e2f0fcc5af05882360689fca5bf (diff)
downloaddjango-rest-framework-cef379db065711bd2f1b0805d28a56f7a80cef37.tar.bz2
2.0 Announcement
Diffstat (limited to 'docs/api-guide/views.md')
-rw-r--r--docs/api-guide/views.md23
1 files changed, 13 insertions, 10 deletions
diff --git a/docs/api-guide/views.md b/docs/api-guide/views.md
index 9e661532..96ce3be7 100644
--- a/docs/api-guide/views.md
+++ b/docs/api-guide/views.md
@@ -120,7 +120,9 @@ You won't typically need to override this method.
REST framework also allows you to work with regular function based views. It provides a set of simple decorators that wrap your function based views to ensure they receive an instance of `Request` (rather than the usual Django `HttpRequest`) and allows them to return a `Response` (instead of a Django `HttpResponse`), and allow you to configure how the request is processed.
-### api_view(http_method_names)
+## @api_view()
+
+**Signature:** `@api_view(http_method_names)
The core of this functionality is the `api_view` decorator, which takes a list of HTTP methods that your view should respond to. For example, this is how you would write a very simple view that just manually returns some data:
@@ -133,7 +135,9 @@ The core of this functionality is the `api_view` decorator, which takes a list o
This view will use the default renderers, parsers, authentication classes etc specified in the [settings](settings).
-To override the default settings, REST framework provides a set of additional decorators which can be added to your views. These must come *after* (below) the `api_view` decorator. For example, to create a view that uses a [throttle](throttling) to ensure it can only be called once per day by a particular user, use the `throttle_classes` decorator, passing a list of throttle classes:
+## API policy decorators
+
+To override the default settings, REST framework provides a set of additional decorators which can be added to your views. These must come *after* (below) the `@api_view` decorator. For example, to create a view that uses a [throttle](throttling) to ensure it can only be called once per day by a particular user, use the `@throttle_classes` decorator, passing a list of throttle classes:
from rest_framework.decorators import api_view, throttle_classes
from rest_framework.throttling import UserRateThrottle
@@ -148,16 +152,15 @@ To override the default settings, REST framework provides a set of additional de
These decorators correspond to the attributes set on `APIView` subclasses, described above.
-### @renderer_classes()
-
-### @parser_classes()
-
-### @authentication_classes()
-
-### @throttle_classes()
+The available decorators are:
-### @permission_classes()
+* `@renderer_classes(...)`
+* `@parser_classes(...)`
+* `@authentication_classes(...)`
+* `@throttle_classes(...)`
+* `@permission_classes(...)`
+Each of these decorators takes a single argument which must be a list or tuple of classes.
[cite]: http://reinout.vanrees.org/weblog/2011/08/24/class-based-views-usage.html
[cite2]: http://www.boredomandlaziness.org/2012/05/djangos-cbvs-are-not-mistake-but.html