mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-03-03 19:00:17 +03:00
Make example more realistic and less of a toy
This commit is contained in:
parent
ae8a827004
commit
34637bf857
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user