seldon/django-simple-accounting — Issue #6: model validation should be performed when receiving ``pre_save`` signal
Author: seldon
Created: 2011-11-20 11:25:02+00:00
State: open
Labels: internals

Model validation logic (as defined by the `.clean()` method on the model's class) must be run *before* the model instance is saved to the database.
There are at least two strategies to achieve this result:
* overriding the `.save()` method for the model
* registering an handler for the `pre_save` Django signal

The former approach is simpler, but it has these two drawbacks:
* it requires a certain amount of boilerplate code (i.e., overriding the `.save()` method for every model just to call `self.full_clean()`)
* more important, validation code is not executed when loading model instances via fixtures (the `pre_save` signal is sent, instead)

So, the second approach seems better that the first one.