mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 12:00:12 +03:00
allowing a new named arg, drf_cookies to the response.Response object so that multiple cookies can be set from within an APIView class
This commit is contained in:
parent
a8d129b7da
commit
2cbc426b9b
|
@ -21,7 +21,7 @@ class Response(SimpleTemplateResponse):
|
||||||
|
|
||||||
def __init__(self, data=None, status=None,
|
def __init__(self, data=None, status=None,
|
||||||
template_name=None, headers=None,
|
template_name=None, headers=None,
|
||||||
exception=False, content_type=None):
|
exception=False, content_type=None, drf_cookies=None):
|
||||||
"""
|
"""
|
||||||
Alters the init arguments slightly.
|
Alters the init arguments slightly.
|
||||||
For example, drop 'template_name', and instead use 'data'.
|
For example, drop 'template_name', and instead use 'data'.
|
||||||
|
@ -48,6 +48,13 @@ class Response(SimpleTemplateResponse):
|
||||||
for name, value in six.iteritems(headers):
|
for name, value in six.iteritems(headers):
|
||||||
self[name] = value
|
self[name] = value
|
||||||
|
|
||||||
|
if drf_cookies:
|
||||||
|
# don't assume rest framework is the innermost handler in the pipeline
|
||||||
|
# so don't clobber other cookies that might already have been set
|
||||||
|
# otherwise self.cookies = drf_cookies would have sufficed
|
||||||
|
for c in drf_cookies:
|
||||||
|
self.cookies[c] = drf_cookies[c].copy()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def rendered_content(self):
|
def rendered_content(self):
|
||||||
renderer = getattr(self, 'accepted_renderer', None)
|
renderer = getattr(self, 'accepted_renderer', None)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user