Change template context generation in TemplateHTMLRenderer (#4236)

- Change the name of ``resolve_context()`` to ``get_template_context()``.
- Pass the renderer context to this method, to give subclasses more flexibility
  when overriding.
This commit is contained in:
René Fleschenberg 2016-08-02 14:11:41 +02:00 committed by Tom Christie
parent e37619f741
commit 9f5e841daf

View File

@ -166,13 +166,14 @@ class TemplateHTMLRenderer(BaseRenderer):
template_names = self.get_template_names(response, view)
template = self.resolve_template(template_names)
context = self.resolve_context(data, request, response)
context = self.get_template_context(data, renderer_context)
return template_render(template, context, request=request)
def resolve_template(self, template_names):
return loader.select_template(template_names)
def resolve_context(self, data, request, response):
def get_template_context(self, data, renderer_context):
response = renderer_context['response']
if response.exception:
data['status_code'] = response.status_code
return data