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

imphil picture imphil  路  13Comments

jeffwidman picture jeffwidman  路  17Comments

pkrasimirov picture pkrasimirov  路  14Comments

Naddiseo picture Naddiseo  路  9Comments

chuwy picture chuwy  路  21Comments