mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-11 12:17:24 +03:00
Allow template to be set on views
This commit is contained in:
parent
cb7a815560
commit
abd3c7b46d
|
@ -182,6 +182,10 @@ class TemplateRenderer(BaseRenderer):
|
||||||
media_type = None
|
media_type = None
|
||||||
template = None
|
template = None
|
||||||
|
|
||||||
|
def __init__(self, view):
|
||||||
|
super(TemplateRenderer, self).__init__(view)
|
||||||
|
self.template = getattr(self.view, "template", self.template)
|
||||||
|
|
||||||
def render(self, obj=None, media_type=None):
|
def render(self, obj=None, media_type=None):
|
||||||
"""
|
"""
|
||||||
Renders *obj* using the :attr:`template` specified on the class.
|
Renders *obj* using the :attr:`template` specified on the class.
|
||||||
|
@ -202,6 +206,10 @@ class DocumentingTemplateRenderer(BaseRenderer):
|
||||||
|
|
||||||
template = None
|
template = None
|
||||||
|
|
||||||
|
def __init__(self, view):
|
||||||
|
super(DocumentingTemplateRenderer, self).__init__(view)
|
||||||
|
self.template = getattr(self.view, "template", self.template)
|
||||||
|
|
||||||
def _get_content(self, view, request, obj, media_type):
|
def _get_content(self, view, request, obj, media_type):
|
||||||
"""
|
"""
|
||||||
Get the content as if it had been rendered by a non-documenting renderer.
|
Get the content as if it had been rendered by a non-documenting renderer.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user