diff --git a/api-guide/reverse.html b/api-guide/reverse.html
index 6f69aeb89..7b9555923 100644
--- a/api-guide/reverse.html
+++ b/api-guide/reverse.html
@@ -122,16 +122,18 @@
reverse
Signature: reverse(viewname, request, *args, **kwargs)
Has the same behavior as django.core.urlresolvers.reverse
, except that it returns a fully qualified URL, using the request to determine the host and port.
-from rest_framework.utils import reverse
+import datetime
+from rest_framework.utils import reverse
from rest_framework.views import APIView
-class MyView(APIView):
+class APIRootView(APIView):
def get(self, request):
- content = {
+ year = datetime.datetime.now().year
+ data = {
...
- 'url': reverse('year-summary', request, args=[1945])
+ 'year-summary-url': reverse('year-summary', request, args=[year])
}
- return Response(content)
+ return Response(data)
reverse_lazy
Signature: reverse_lazy(viewname, request, *args, **kwargs)
diff --git a/api-guide/views.html b/api-guide/views.html
index d03d6a02c..4e40aced9 100644
--- a/api-guide/views.html
+++ b/api-guide/views.html
@@ -94,11 +94,12 @@
@@ -106,7 +107,7 @@
decorators.py views.py
-
Views
+
Class Based Views
Django's class based views are a welcome departure from the old-style views.
— Reinout van Rees
@@ -177,6 +178,13 @@ This method is used to enforce permissions and throttling, and perform content n
.finalize_response(self, request, response, args, *kwargs)
Ensures that any Response
object returned from the handler method will be rendered into the correct content type, as determined by the content negotation.
You won't typically need to override this method.
+Function Based Views
+
+Saying [that Class based views] is always the superior solution is a mistake.
+— Nick Coghlan
+
+REST framework also gives you to work with regular function based views...
+[TODO]