#18369 closed Cleanup/optimization (fixed)
Documentation error with django.shortcuts.render() function
Reported by: | Owned by: | Tim Graham | |
---|---|---|---|
Component: | Documentation | Version: | 1.4 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I suppose there is one tiny error in description of django.shortcuts.render
function in Django documentation
https://docs.djangoproject.com/en/1.4/topics/http/shortcuts/
It's said there that its second argument named template
. As I see from sources this function internally passes
almost all its argument to loader.render_to_string
using *args and **kwargs like render_to_response
do.
But loader.render_to_string
is defined as
render_to_string(template_name, dictionary=None, context_instance=None)
so if you call render
using key-words arguments e.g.
render(request=request, template='path/to/template.html')
or attempt to use it as simple view instead of TemplateView e.g
url(r'^some-url/$', render, {'template': 'path/to/template.html'})
you get TypeError
with message "render_to_string() got an unexpected keyword argument 'template'"
.
I think it'll be better to use template_name
as name of argument instead of template
in documentation for the render
shortcut.
Change History (4)
comment:1 by , 13 years ago
comment:2 by , 12 years ago
Owner: | changed from | to
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
In [1cf8287e3a6f252b79e9b9a8f945f11a92e17cd5]: