So, in template.html I use:
{% if dict %}
{{ s={} }}
{% endif %}
The error is – Could not parse the remainder: ‘={}’ from ‘s={}’. How to fix it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Django templates shouldn’t really be used for making dictionaries, they should be made in your views and only basic processing should be done in the templates.
It’s this way on purpose to strictly adhere to the MVC design pattern.
See from here: https://docs.djangoproject.com/en/dev/topics/templates/
By the looks of things you want to create a
dictbased on some condition. You should probably rearrange your logic and create thedictin the view — you also get to leverage all the power of python this way.There’s probably be a ton of workarounds for your situation if you describe it in more detail.