Jinja Errors

In this article, we explain some of the errors that you can come across when using Jinja in Bloomreach Engagement.

Error 1: "'NoneType' object is not iterable"

The error occurs when Jinja tries to iterate some empty, not existing or not iterable object. To solve this check, whether the object in the condition exists and is iterable for the customer you are previewing the code for.

Error 2: "Not supported between instances of 'NoneType' and 'int'"

The error occurs in Jinja when you are trying to compare the null element with some value. For example, when catalogue value item.price is empty and email contains comparison {% if item.price > 0 %}. To solve this, check whether the element is not null or set the elements to be compared only if the items' values are higher than zero. For example, {% if item.price %}{% if item.price > 0 %}.

Error 3: > "Not supported between instances of 'str' and 'int'"

The error occurs when an element with datatype "string" is compared to a number. For example, {% if "3" > 0 %}. To solve this, use a jinja filter to convert the data type to a number (int or float). The result could look like this: {% if "3"|int > 0 %}.

Error 4: "Template rendering timeout"

The error occurs when jinja is too complex. For example, when there are too many calls in catalogs or recommendations, too long computing time for jinja, or too many layers of iterations ("for" and "if" cycles). To solve this, simplify and optimize the jinja you are using.

Did this page help you?