From 13110a386c9d72feee8cc11f0f45024ba1d8a9f2 Mon Sep 17 00:00:00 2001 From: Daniel Izquierdo Date: Mon, 20 Feb 2012 18:46:47 +0900 Subject: [PATCH] Implement a custom reverse that builds absolute URLs with a request object --- djangorestframework/utils/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/djangorestframework/utils/__init__.py b/djangorestframework/utils/__init__.py index ba2f6e05b..f72e0046d 100644 --- a/djangorestframework/utils/__init__.py +++ b/djangorestframework/utils/__init__.py @@ -1,6 +1,6 @@ from django.utils.encoding import smart_unicode from django.utils.xmlutils import SimplerXMLGenerator -from django.core.urlresolvers import resolve, reverse +from django.core.urlresolvers import resolve, reverse as django_reverse from django.conf import settings from djangorestframework.compat import StringIO @@ -174,5 +174,6 @@ class XMLRenderer(): def dict2xml(input): return XMLRenderer().dict2xml(input) -def reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None, current_app=None): - raise NotImplementedError + +def reverse(viewname, request, *args, **kwargs): + return request.build_absolute_uri(django_reverse(viewname, *args, **kwargs))