Check is DJANGO object is valid

django

Solution

Yes: https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.full_clean

instance = MyModel.objects.get(pk=1)
instance.field1 = some_value
instance.full_clean()

This is called automatically when you save a model via a modelform (eg `instance = myform.save()`), but not when you just do `instance.save()`.

Problem

I have DJANGO model object, not form. Is there a function to check is model valid? With forms I have `form.is_valid():`

Original source

Related problems