Currently, we have lots of data validation put into the forms. However, creating data from other code-paths (within Python code or from the shell) doesn't use that validation code.
All validation that is not form-specific (i.e. doesn't require user interacation) should be pushed into the Model.clean method. In Django, this is the place for custom validation. You specify the field of validation by passing a dictionary when raising a ValidationError error (where the key is the field name that was invalid).
Currently, we have lots of data validation put into the forms. However, creating data from other code-paths (within Python code or from the shell) doesn't use that validation code.
All validation that is not form-specific (i.e. doesn't require user interacation) should be pushed into the
Model.clean
method. In Django, this is the place for custom validation. You specify the field of validation by passing a dictionary when raising aValidationError
error (where the key is the field name that was invalid).https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.clean