|
@@ -8,7 +8,9 @@ class ContentNotRenderedError(Exception):
|
|
|
|
|
|
|
|
|
class SimpleTemplateResponse(HttpResponse):
|
|
|
- rendering_attrs = ["template_name", "context_data", "_post_render_callbacks"]
|
|
|
+ non_picklable_attrs = HttpResponse.non_picklable_attrs | frozenset(
|
|
|
+ ["template_name", "context_data", "_post_render_callbacks"]
|
|
|
+ )
|
|
|
|
|
|
def __init__(
|
|
|
self,
|
|
@@ -55,16 +57,11 @@ class SimpleTemplateResponse(HttpResponse):
|
|
|
Raise an exception if trying to pickle an unrendered response. Pickle
|
|
|
only rendered data, not the data used to construct the response.
|
|
|
"""
|
|
|
- obj_dict = self.__dict__.copy()
|
|
|
if not self._is_rendered:
|
|
|
raise ContentNotRenderedError(
|
|
|
"The response content must be rendered before it can be pickled."
|
|
|
)
|
|
|
- for attr in self.rendering_attrs:
|
|
|
- if attr in obj_dict:
|
|
|
- del obj_dict[attr]
|
|
|
-
|
|
|
- return obj_dict
|
|
|
+ return super().__getstate__()
|
|
|
|
|
|
def resolve_template(self, template):
|
|
|
"""Accept a template object, path-to-template, or list of paths."""
|
|
@@ -145,7 +142,9 @@ class SimpleTemplateResponse(HttpResponse):
|
|
|
|
|
|
|
|
|
class TemplateResponse(SimpleTemplateResponse):
|
|
|
- rendering_attrs = SimpleTemplateResponse.rendering_attrs + ["_request"]
|
|
|
+ non_picklable_attrs = SimpleTemplateResponse.non_picklable_attrs | frozenset(
|
|
|
+ ["_request"]
|
|
|
+ )
|
|
|
|
|
|
def __init__(
|
|
|
self,
|