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.
It's
django.template.backends.django.Template.render()
that can't be called withContext
.django.template.Template.render()
must be called withContext
.