[Django]-Context processors and manual rendering

2👍

✅

Let’s see what the render documentation says:

Template.render(context=None, request=None)
Renders this template
with a given context.

If context is provided, it must be a dict. If it isn’t provided, the
engine will render the template with an empty context.

If request is provided, it must be an HttpRequest. Then the engine
must make it, as well as the CSRF token, available in the template.
How this is achieved is up to each backend.

Here’s an example of the search algorithm. For this example the
TEMPLATES setting is:

The second parameter is the request! So we have

 new_body = tmpl8.render(render_context, request)

1👍

Try to pass request to render() method:

new_body = tmpl8.render({ 'rows': MyModel.custom_query() }, request)

Leave a comment