mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
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:
parent
e37619f741
commit
9f5e841daf
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user