aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework
diff options
context:
space:
mode:
authorMeurig Freeman2011-10-31 03:58:00 +0000
committerMeurig Freeman2011-10-31 03:58:00 +0000
commit5541f0af448bfdfbc212deddca6571314446a071 (patch)
tree2f30b3f8c5696bba8364246bf1c1b2299433e2b9 /djangorestframework
parent2caf879f22c013e9d29e1cd78e77bb6578bc0ee3 (diff)
downloaddjango-rest-framework-5541f0af448bfdfbc212deddca6571314446a071.tar.bz2
make use of original prefix when generating absolute urls
Diffstat (limited to 'djangorestframework')
-rw-r--r--djangorestframework/views.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/djangorestframework/views.py b/djangorestframework/views.py
index 5f8e84cd..f8434b40 100644
--- a/djangorestframework/views.py
+++ b/djangorestframework/views.py
@@ -5,7 +5,7 @@ be subclassing in your implementation.
By setting or modifying class attributes on your view, you change it's predefined behaviour.
"""
-from django.core.urlresolvers import set_script_prefix
+from django.core.urlresolvers import set_script_prefix, get_script_prefix
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
@@ -113,8 +113,9 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
self.headers = {}
# Calls to 'reverse' will not be fully qualified unless we set the scheme/host/port here.
+ orig_prefix = get_script_prefix()
prefix = '%s://%s' % (request.is_secure() and 'https' or 'http', request.get_host())
- set_script_prefix(prefix)
+ set_script_prefix(prefix + orig_prefix)
try:
self.initial(request, *args, **kwargs)
@@ -156,6 +157,8 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
# merge with headers possibly set at some point in the view
response.headers.update(self.headers)
+ set_script_prefix(orig_prefix)
+
return self.render(response)