mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 08:14:16 +03:00
Implement `reverse_lazy()'
This commit is contained in:
parent
6f4fab81d2
commit
f17f3886f4
|
@ -1,3 +1,4 @@
|
|||
import django
|
||||
from django.utils.encoding import smart_unicode
|
||||
from django.utils.xmlutils import SimplerXMLGenerator
|
||||
from django.core.urlresolvers import resolve, reverse as django_reverse
|
||||
|
@ -181,3 +182,13 @@ def reverse(viewname, request, *args, **kwargs):
|
|||
*request* to build a fully qualified URL.
|
||||
"""
|
||||
return request.build_absolute_uri(django_reverse(viewname, *args, **kwargs))
|
||||
|
||||
if django.VERSION >= (1, 4):
|
||||
from django.core.urlresolvers import reverse_lazy as django_reverse_lazy
|
||||
|
||||
def reverse_lazy(viewname, request, *args, **kwargs):
|
||||
"""
|
||||
Do the same as :py:func:`django.core.urlresolvers.reverse_lazy` but using
|
||||
*request* to build a fully qualified URL.
|
||||
"""
|
||||
return request.build_absolute_uri(django_reverse_lazy(viewname, *args, **kwargs))
|
||||
|
|
Loading…
Reference in New Issue
Block a user