Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
75d6446c
Commit
75d6446c
authored
Sep 26, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow .template_name attribute specified on view. Closes #1000
parent
e8c6cd56
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
rest_framework/renderers.py
+9
-2
No files found.
rest_framework/renderers.py
View file @
75d6446c
...
...
@@ -272,7 +272,9 @@ class TemplateHTMLRenderer(BaseRenderer):
return
[
self
.
template_name
]
elif
hasattr
(
view
,
'get_template_names'
):
return
view
.
get_template_names
()
raise
ImproperlyConfigured
(
'Returned a template response with no template_name'
)
elif
hasattr
(
view
,
'template_name'
):
return
[
view
.
template_name
]
raise
ImproperlyConfigured
(
'Returned a template response with no `template_name` attribute set on either the view or response'
)
def
get_exception_template
(
self
,
response
):
template_names
=
[
name
%
{
'status_code'
:
response
.
status_code
}
...
...
@@ -388,7 +390,7 @@ class HTMLFormRenderer(BaseRenderer):
# likely change at some point.
self
.
renderer_context
=
renderer_context
or
{}
request
=
renderer_context
[
'request'
]
request
=
self
.
renderer_context
[
'request'
]
# Creating an on the fly form see:
# http://stackoverflow.com/questions/3915024/dynamically-creating-classes-python
...
...
@@ -419,8 +421,13 @@ class BrowsableAPIRenderer(BaseRenderer):
"""
renderers
=
[
renderer
for
renderer
in
view
.
renderer_classes
if
not
issubclass
(
renderer
,
BrowsableAPIRenderer
)]
non_template_renderers
=
[
renderer
for
renderer
in
renderers
if
not
hasattr
(
renderer
,
'get_template_names'
)]
if
not
renderers
:
return
None
elif
non_template_renderers
:
return
non_template_renderers
[
0
]()
return
renderers
[
0
]()
def
get_content
(
self
,
renderer
,
data
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment