diff options
| author | Tom Christie | 2012-10-02 19:54:24 +0100 |
|---|---|---|
| committer | Tom Christie | 2012-10-02 19:54:24 +0100 |
| commit | e1518de68fa9ad4b2628894abf17924e386ccbda (patch) | |
| tree | b1d190f6bd08ce087cf0a2d3e8cd681b5e7e7d04 /docs/api-guide/reverse.md | |
| parent | 31b06f1721f98730556dc56927b985e4032788c3 (diff) | |
| parent | d1b99f350aded62fe480f7dc4749cd63d52715d2 (diff) | |
| download | django-rest-framework-e1518de68fa9ad4b2628894abf17924e386ccbda.tar.bz2 | |
Merge branch 'restframework2' of https://github.com/tomchristie/django-rest-framework into restframework2
Diffstat (limited to 'docs/api-guide/reverse.md')
| -rw-r--r-- | docs/api-guide/reverse.md | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/docs/api-guide/reverse.md b/docs/api-guide/reverse.md index 3fa654c0..8485087e 100644 --- a/docs/api-guide/reverse.md +++ b/docs/api-guide/reverse.md @@ -19,22 +19,28 @@ REST framework provides two utility functions to make it more simple to return a There's no requirement for you to use them, but if you do then the self-describing API will be able to automatically hyperlink it's output for you, which makes browsing the API much easier. -## reverse(viewname, request, *args, **kwargs) +## reverse + +**Signature:** `reverse(viewname, request, *args, **kwargs)` 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 -## reverse_lazy(viewname, request, *args, **kwargs) +**Signature:** `reverse_lazy(viewname, request, *args, **kwargs)` Has the same behavior as [`django.core.urlresolvers.reverse_lazy`][reverse-lazy], except that it returns a fully qualified URL, using the request to determine the host and port. |
