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

The-Compiler picture The-Compiler  路  4Comments

Yannik picture Yannik  路  4Comments

DriverX picture DriverX  路  4Comments

priestc picture priestc  路  5Comments

Xion picture Xion  路  5Comments