Created
April 13, 2012 21:50
-
-
Save juliomistral/2380377 to your computer and use it in GitHub Desktop.
Django model mixin to force validation on any create/save
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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