Warnings (or even info messages) instead of only errors in Django

后端 未结 3 1027
小蘑菇
小蘑菇 2021-01-02 06:36

Does the concept of severity exist in Django\'s form validation or is it only errors?

Also, how about suppressing warnings/errors?

3条回答
  •  醉话见心
    2021-01-02 07:26

    Django forms can only raise ValidationErrors (see here). One way to get around this is to use the new messaging system. There are 5 levels of messages defined, with the ability to define additional custom message levels.

    As for suppressing errors/warnings, you can always simply ignore form.errors in your template. Also take a look at the clean methods in the forms module - you should be able to suppress some warnings there.

提交回复
热议问题