1👍
To fix the issue, you can remove the duplicate block definition and move the contents of the if-else statement into a single block definition.
Try this:
{% block name %}
{% if object.name == '' %}
{{ object.name }}
{% else %}
{{ object.alternate_name }}
{% endif %}
{% endblock name %}
0👍
You can not make blocks conditional: these are nodes that are directly at the level of {% extends %}
. You can move the condition into the block:
{% block name %}
{% if object.name == '' %}
{{ object.name}}
{% else %}
{{ object.alternate_name}}
{% endif %}
{% endblock name %}
that being said, the condition should probably be reversed. You can also probably use {% firstof … %}
[Django-doc]:
{% block name %}
{% firstof object.name object.alternate_name %}
{% endblock name %}
- [Answered ]-Delete pieces of Session on browser close
- [Answered ]-POST request using ajax in Django
- [Answered ]-Django: set up a scheduled job within Django?
- [Answered ]-Kick off daemonized service using djangos manage.py custom command?
Source:stackexchange.com