mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-04-28 13:03:45 +03:00
Merge meurig's absolute_url fix.
This commit is contained in:
commit
42cdd00591
1
AUTHORS
1
AUTHORS
|
@ -18,6 +18,7 @@ Tom Drummond <devioustree>
|
|||
Danilo Bargen <gwrtheyrn>
|
||||
Andrew McCloud <amccloud>
|
||||
Thomas Steinacher <thomasst>
|
||||
Meurig Freeman <meurig>
|
||||
|
||||
THANKS TO:
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -114,8 +114,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)
|
||||
|
@ -162,13 +163,14 @@ 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)
|
||||
|
||||
|
||||
def options(self, request, *args, **kwargs):
|
||||
def options(self, request, *args, **kwargs):
|
||||
response_obj = {
|
||||
'name' : get_name(self),
|
||||
'description' : get_description(self),
|
||||
'name': get_name(self),
|
||||
'description': get_description(self),
|
||||
'renders': self._rendered_media_types,
|
||||
'parses': self._parsed_media_types,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user