2
Calling full_clean()
is the correct way to validate a model instance.
from django.core.exceptions import ValidationError
try:
obj.full_clean()
except ValidationError:
# handle invalid object
When dealing with a model form, calling is_valid()
will perform the model validation, so you don’t have to call full_clean()
manually.
Calling save()
with commit=False
doesn’t perform model validation. Instead, it gives you the opportunity to change the object before you save it to the database. A common example is to set the user attribute to the user that is currently logged on.
Source:stackexchange.com