Make example more realistic and less of a toy

This commit is contained in:
Tom Christie 2012-10-02 11:03:51 +01:00
parent ae8a827004
commit 34637bf857

View File

@ -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. 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.utils import reverse
from rest_framework.views import APIView from rest_framework.views import APIView
class MyView(APIView): class APIRootView(APIView):
def get(self, request): 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 ## reverse_lazy