WTforms form not submitting but outputs no validation errors

后端 未结 1 574
后悔当初
后悔当初 2021-02-11 02:08

I\'m trying to get file uploads with flask-uploads working and running in to some snags. I\'ll show you my flask view function, the html and hopefully

1条回答
  •  醉梦人生
    2021-02-11 03:04

    You have csrf_enabled=True but your form doesn't have any CSRF protection since you aren't inheriting from SecureForm. If you want to enable CSRF, read the documentation and update your form definition.

    If this was unintended, you can remove csrf_enabled=True and your logic will work as expected.

    To enable CSRF protection, there are a few steps:

    1. Inherit from SecureForm
    2. Create the generate_csrf_token and validate_csrf_token methods in your form. These methods will generate a unique key and raise errors when it doesn't validate.
    3. Add {{ form.csrf_token }} to your template.

    0 讨论(0)
提交回复
热议问题