Opened 10 years ago
Closed 10 years ago
#24785 closed Bug (needsinfo)
render_to_string makes invalid call to template.render
Reported by: | Dan Poirier | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Line 92 in django/template/loader.py, here: https://github.com/django/django/blob/bd53db5eab05099ae371348529c6428e0da95c6a/django/template/loader.py#L92
return template.render(context, request)
calls template.render with two arguments.
But template.render here: https://github.com/django/django/blob/bd53db5eab05099ae371348529c6428e0da95c6a/django/template/base.py#L209
def render(self, context):
only takes one argument. Here's the resulting error:
File ".../lib/python3.4/site-packages/django/template/loader.py", line 99, in render_to_string return template.render(context, request) TypeError: render() takes 2 positional arguments but 3 were given
Note:
See TracTickets
for help on using tickets.
In the first piece of code you're quoting, template is expected to be a backend-dependent
Template
wrapper as specified in DEP 182, for exampledjango.template.backends.django.Template
.The second piece of code refers to
django.template.base.Template
. I don't have enough information about your project to say why you're getting the wrong type of template there.Can you check the 1.8 release notes and upgrade instructions to make sure you updated your code appropriately?