Skip to content

Instantly share code, notes, and snippets.

@juliomistral
Created April 13, 2012 21:50
Show Gist options
  • Save juliomistral/2380377 to your computer and use it in GitHub Desktop.
Save juliomistral/2380377 to your computer and use it in GitHub Desktop.
Django model mixin to force validation on any create/save
class ValidateOnPersistMixin(models.Model):
class Meta:
abstract = True
def save(self, force_insert=False, force_update=False, using=None):
self.full_clean()
super(ValidateOnPersistMixin, self).save(force_insert, force_update, using)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment