Django model data consistency
- by Mark
When creating a form, you can define a bunch of methods, clean_xyz, to make sure the data gets forced into the correct format. Is there any way to do this on a model level?
Perhaps I can override the field setters somehow? I want it so that if I write something like
my_address.postal_code = 'a1b2c3'
It will automatically get formatted into A1B 2C3. Perhaps throw an exception if it can't be converted. That way I know I'll never have any malformed data in the database.