diff --git a/django/template/response.py b/django/template/response.py index 7741a3e3ad..990a17b6bf 100644 --- a/django/template/response.py +++ b/django/template/response.py @@ -21,10 +21,6 @@ class SimpleTemplateResponse(HttpResponse): self.template_name = template self.context_data = context - # _is_rendered tracks whether the template and context has been - # baked into a final response. - self._is_rendered = False - self._post_render_callbacks = [] # content argument doesn't make sense here because it will be replaced @@ -33,6 +29,14 @@ class SimpleTemplateResponse(HttpResponse): super(SimpleTemplateResponse, self).__init__('', mimetype, status, content_type) + # _is_rendered tracks whether the template and context has been baked + # into a final response. + # Super __init__ doesn't know any better than to set self.content to + # the empty string we just gave it, which wrongly sets _is_rendered + # True, so we initialize it to False after the call to super __init__. + self._is_rendered = False + + def __getstate__(self): """Pickling support function.