Opened 6 years ago

Closed 6 years ago

#29639 closed Bug (invalid)

Fault in the documentation around usage of Context versus dict

Reported by: JeroenPeterBos Owned by: nobody
Component: Documentation Version: 2.1
Severity: Normal Keywords: Deprecated Usage
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Problem
In the documentation on the following page there is a mistake:
https://docs.djangoproject.com/en/2.1/ref/templates/api/#django.template.Template.render

Under Rendering a context -> Template.render(context) it is demonstrated how to render a context onto a template.
However doing this results in the error: TypeError: context must be a dict rather than Context.

I have found that this usage of the Context class is deprecated in Django 1.10+.

Solution
The documentation regarding Rendering a Context should be updated to insert a dictionary instead of first creating a Context and passing that to the render function.

Change History (1)

comment:1 by Tim Graham, 6 years ago

Resolution: invalid
Status: newclosed

It's django.template.backends.django.Template.render() that can't be called with Context. django.template.Template.render() must be called with Context.

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