Distinguish between None and False/0/[] in a template?

21 views
Skip to first unread message

Christophe Pettus

unread,
Dec 6, 2010, 2:31:13 PM12/6/10
to Django users
Pardon if this is a FAQ, but is there a built-in way of distinguishing between None and the other typical false values (False/0/[]) in a template? Something along the lines of:

{% if var == None %} ... {% endif %}

Thanks!
--
-- Christophe Pettus
x...@thebuild.com

Łukasz Rekucki

unread,
Dec 6, 2010, 3:22:35 PM12/6/10
to django...@googlegroups.com
On 6 December 2010 20:31, Christophe Pettus <x...@thebuild.com> wrote:
> Pardon if this is a FAQ, but is there a built-in way of distinguishing between None and the other typical false values (False/0/[]) in a template?  Something along the lines of:
>
>        {% if var == None %} ... {% endif %}
>

It's best to just try before asking if something works :) There is a
filter variant too:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#default-if-none

--
Łukasz Rekucki

Reply all
Reply to author
Forward
0 new messages