Jinja: no test named 'None'

Created on 13 Dec 2015  ·  2Comments  ·  Source: pallets/jinja

Running into an issue where using a template like this {{"" if np is None else np}}, I get the following exception jinja2.exceptions.TemplateAssertionError: no test named 'None'. Trying with is not has similar problems.

Most helpful comment

Use lowercase none.

Jinja's is is different from Python's is. It invokes functions registered as "tests". And while there's a none test, there's no test named None.


Useful side-note: Jinja also uses lowercase for true and false, even though the python-cased True and False work too.

All 2 comments

Use lowercase none.

Jinja's is is different from Python's is. It invokes functions registered as "tests". And while there's a none test, there's no test named None.


Useful side-note: Jinja also uses lowercase for true and false, even though the python-cased True and False work too.

Thanks @ThiefMaster. I'm still pretty new to jinja, but it seems pretty cool. Thanks for the pointers too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hvnsweeting picture hvnsweeting  ·  4Comments

dwt picture dwt  ·  3Comments

DriverX picture DriverX  ·  4Comments

mitsuhiko picture mitsuhiko  ·  3Comments

humiaozuzu picture humiaozuzu  ·  3Comments