mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
importing SimpleTemplateResponse from compat module
to use the newer __getstate__ implementation using the rendering_attrs property
This commit is contained in:
parent
75e5573865
commit
dd09e94f41
|
@ -6,8 +6,7 @@ The appropriate renderer is called during Django's template response rendering.
|
||||||
"""
|
"""
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from django.core.handlers.wsgi import STATUS_CODE_TEXT
|
from django.core.handlers.wsgi import STATUS_CODE_TEXT
|
||||||
from django.template.response import SimpleTemplateResponse
|
from rest_framework.compat import six, SimpleTemplateResponse
|
||||||
from rest_framework.compat import six
|
|
||||||
|
|
||||||
|
|
||||||
class Response(SimpleTemplateResponse):
|
class Response(SimpleTemplateResponse):
|
||||||
|
@ -15,6 +14,8 @@ class Response(SimpleTemplateResponse):
|
||||||
An HttpResponse that allows its data to be rendered into
|
An HttpResponse that allows its data to be rendered into
|
||||||
arbitrary media types.
|
arbitrary media types.
|
||||||
"""
|
"""
|
||||||
|
rendering_attrs = SimpleTemplateResponse.rendering_attrs + \
|
||||||
|
['accepted_renderer', 'renderer_context', 'data']
|
||||||
|
|
||||||
def __init__(self, data=None, status=200,
|
def __init__(self, data=None, status=200,
|
||||||
template_name=None, headers=None,
|
template_name=None, headers=None,
|
||||||
|
@ -76,13 +77,3 @@ class Response(SimpleTemplateResponse):
|
||||||
# TODO: Deprecate and use a template tag instead
|
# TODO: Deprecate and use a template tag instead
|
||||||
# TODO: Status code text for RFC 6585 status codes
|
# TODO: Status code text for RFC 6585 status codes
|
||||||
return STATUS_CODE_TEXT.get(self.status_code, '')
|
return STATUS_CODE_TEXT.get(self.status_code, '')
|
||||||
|
|
||||||
def __getstate__(self):
|
|
||||||
"""
|
|
||||||
Remove attributes from the response that shouldn't be cached
|
|
||||||
"""
|
|
||||||
state = super(Response, self).__getstate__()
|
|
||||||
for key in ('accepted_renderer', 'renderer_context', 'data'):
|
|
||||||
if key in state:
|
|
||||||
del state[key]
|
|
||||||
return state
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user