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)
- [Django]-Pillow Resizing images (thumbnail) on Amazon S3 – Django
- [Django]-Django ManyToMany relationship with abstract base – not possible, but is there a better way?
- [Django]-How to load bootstrapped models of backbone in Django
- [Django]-Posting complex data dictionary with request python
- [Django]-How to create views automatically from model as in Django admin?
Source:stackexchange.com