Released django-check-constraints

Mon 15 March 2010 by Thejaswi Puthraya

Ever since model validation hit the django trunk, I had been having thoughts of reviving my Google Summer of Code 2007 project. So nearly a couple of weeks back, I started resurrecting django-check-constraints. Today, I released the code into wild here.

The feature of the project is that it not only generates the required SQL statements for creating the constraints during syncdb but also adds validators to the model fields so that any errors can be gracefully handled exactly like normal model validation. All this without having to write extra validation in the form or model!

The usage is fairly simple.

  • Define the constraints in the inner Meta class of the model
  • Override the model's metaclass with the CheckConstraintMetaClass provided.

Here are some screenshots (they say a picture is worth a thousand words):

Model definition for django-check-constraints SQL generated for the model Validators at work using django-check-constraints