aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/reverse.md
diff options
context:
space:
mode:
authorTom Christie2012-10-02 11:03:51 +0100
committerTom Christie2012-10-02 11:03:51 +0100
commit34637bf8578bdfff2d60f36e6e5ac6314a330eaf (patch)
tree92012d0b3f7a06095ad075899dea1bc2d9324a38 /docs/api-guide/reverse.md
parentae8a8270042820f92b9d43597bde50d72c300513 (diff)
downloaddjango-rest-framework-34637bf8578bdfff2d60f36e6e5ac6314a330eaf.tar.bz2
Make example more realistic and less of a toy
Diffstat (limited to 'docs/api-guide/reverse.md')
-rw-r--r--docs/api-guide/reverse.md10
1 files changed, 6 insertions, 4 deletions
diff --git a/docs/api-guide/reverse.md b/docs/api-guide/reverse.md
index 07094e6f..8485087e 100644
--- a/docs/api-guide/reverse.md
+++ b/docs/api-guide/reverse.md
@@ -25,16 +25,18 @@ There's no requirement for you to use them, but if you do then the self-describi
Has the same behavior as [`django.core.urlresolvers.reverse`][reverse], except that it returns a fully qualified URL, using the request to determine the host and port.
+ 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