Reputation: 4493
I am passing an object to my Jinja2 template to be used as form values.
If a property doesn't exist, it is printing None
as a string, where I would like it to just print an empty string (aka, nothing).
As there are a lot of properties for the object, I wish to avoid string coercion at the Controller level.
My current Jinja code looks like:
value="{{ my_object.my_property }}"
Upvotes: 2
Views: 584
Reputation: 4493
I was able to utilize the following, which is not too long:
{{ my_object.my_property or '' }}
Upvotes: 1