Flask unit test throwing Error: has no attribute 'csrf_token' in Jinja2 template Flask unit test throwing Error: has no attribute 'csrf_token' in Jinja2 template flask flask

Flask unit test throwing Error: has no attribute 'csrf_token' in Jinja2 template


In your jinja template first check to see if the value is set, and then if it is include it.

{% if 'csrf_token' in form %}  {{form.csrf_token}}{% endif %}