[Django]-Modelform: override clean method

26👍

For 1, Yes, if you want to make use of parent class’s validators. See this explanation on the doc.

Warning

The ModelForm.clean() method sets a flag that makes the model
validation step validate the uniqueness of model fields that are
marked as unique, unique_together or unique_for_date|month|year.

If you would like to override the clean() method and maintain this
validation, you must call the parent class’s clean() method.

For 2, yes, if data validates properly. Otherwise raise validation error.

👤Rohan

Leave a comment