mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
adding support for rendering_attrs in SimpleTemplateResponse
__getstate__ method in django < 1.4 the implementation changed a bit in recent versions and it’s not hardcoded anymore its using the rendering_attrs to better support customising pickle
This commit is contained in:
parent
299a8347e8
commit
75e5573865
|
@ -600,3 +600,20 @@ except ImportError:
|
||||||
klass.__unicode__ = klass.__str__
|
klass.__unicode__ = klass.__str__
|
||||||
klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
|
klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
|
||||||
return klass
|
return klass
|
||||||
|
|
||||||
|
|
||||||
|
from django.template.response import SimpleTemplateResponse as _SimpleTemplateResponse
|
||||||
|
if django.VERSION > (1, 4):
|
||||||
|
SimpleTemplateResponse = _SimpleTemplateResponse
|
||||||
|
else:
|
||||||
|
class SimpleTemplateResponse(_SimpleTemplateResponse):
|
||||||
|
rendering_attrs = []
|
||||||
|
|
||||||
|
def __getstate__(self):
|
||||||
|
state = super(SimpleTemplateResponse, self).__getstate__()
|
||||||
|
#apply the same logic django > 1.4 implements
|
||||||
|
for key in self.rendering_attrs:
|
||||||
|
if key in state:
|
||||||
|
del state[key]
|
||||||
|
|
||||||
|
return state
|
||||||
|
|
Loading…
Reference in New Issue
Block a user