we should systematically enforce model constraints on .save()
Django has a nasty bugfeature: while we can define many constraints to the models, django does not enforce anything automatically. All validations are to be done manually, and its very easy to miss one of them.
This issue is describe in details here: https://www.xormedia.com/django-model-validation-on-save/
In the implementation of !105 (merged), I added the checks at places that are obvious (03d50ab3 and 63034452), but there are many other places that should be checked.
I think we should apply the solution recommended in the page above: we should derive all our models from a common base class that reimplements save() to enforce these checks every time an object is created or updated.
Example:
class BaseModel(models.Model):
def save(self, force_insert=False, force_update=False, **kw):
if not (force_insert or force_update):
self.full_clean()
super().save(force_insert, force_update, **kw)