Closed AdrienHorgnies closed 4 years ago
That's how Django validation generally works. Model cleaning is automatically called when you receive values through Django forms. If you programmatically build a model instance, it's your duty to call field validation.
Version: "Django==3.0.6", "django-localflavor==3.0.1"
I used localflavor.generic.models.IBANField for a Django models.Model attribute and it seems it accepts any value. I expect it to throw an exception or something when it receives an invalid value, but it's stores it in database like if the value is valid.
After some debugging, I see that calling the method
clean_fields
on such an instance throw indeed a ValidationError. But it doesn't happen when creating the instance... Did I do something wrong ? Or am I supposed to do something special for validation to occur ?