Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#18369 closed Cleanup/optimization (fixed)

Documentation error with django.shortcuts.render() function

Reported by: qsolo825@… 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 anonymous, 13 years ago

comment:2 by Tim Graham, 13 years ago

Owner: changed from nobody to Tim Graham
Triage Stage: UnreviewedAccepted

comment:3 by Tim Graham <timgraham@…>, 12 years ago

Resolution: fixed
Status: newclosed

In [1cf8287e3a6f252b79e9b9a8f945f11a92e17cd5]:

Fixed #18369 - Fixed argument name in render() function; thanks qsolo825@ for the report.

comment:4 by Tim Graham <timgraham@…>, 12 years ago

In [3631a028e2d8eef9ade7b174d9cbe1440d4acfad]:

[1.4.X] Fixed #18369 - Fixed argument name in render() function; thanks qsolo825@ for the report.

Backport of 1cf8287e3a from master

Note: See TracTickets for help on using tickets.
Back to Top