Determine empty template variable in Django
Just use {% if narratives.narrative_text %}
, I think. It will use Python's implicit false, which applies for empty strings, empty arrays, empty dicts, None
, False
, 0
etc..
Pipe through length and do your test against that value.
{% if narratives.narrative_text|length > 0 %}
{{ narratives.narrative_text }}
{% else %}
None
{% endif %}