Validating Model subclass

1
2
3
4
5
6
7
class ValidatedModel(models.Model):
    def save(self, *args, **kwargs):
        self.full_clean()
        super(ValidatedModel, self).save(*args, **kwargs)

    class Meta:
        abstract = True

More like this

  1. Run model validation before saving a model instance by buriy 2 years, 4 months ago
  2. Character encoding fix by mrtron 5 years ago
  3. Render markdown to a separate model field by mindcruzer 8 months ago
  4. "Autoconnect" model decorator, easy pre_save and post_save signal connection by bendavis78 2 years, 10 months ago
  5. decorator to add GUID Field to Django Models by trubliphone 3 months, 2 weeks ago

Comments

(Forgotten your password?)