Does the concept of severity exist in Django\'s form validation or is it only errors?
Also, how about suppressing warnings/errors?
Old question, but I think it is still relevant.
It really depends on what you consider to be a warning.
contrib.messages
framework (or similar), you may display a warning box on the next page (be it the same form page, or a redirection to home or any other page)Alternatively, you might want confirmation instead of a warning. You may add or alter fields dynamically upon creation, so why not add hidden "I accept the risks" checkboxes that are required only if your form raises that warning?
The second option has the advantage of not requiring cookies, and it also adds interactivity (your user might not want to proceed because of the warning...).
In your code, all you would have to do is this:
#views.py
...
if form.is_valid():
# proceed
else:
form.fields["my_checkbox"].widget = widgets.CheckboxInput
# re-display form
...
#forms.py
...
def clean_myfield(self):
# do your cleaning
if (myfield_warning==True) and not (my_checkbox==True):
raise ValidationError("blabla")
else:
return myfield
In your view, you may check for appropriate errors in form.errors if needed.