Django check constraints is a project that implements check constraints on models. The various check constraints implemented are:
- Range Based Check Constraints
- Value Based Check Constraints
These constraints are added at the database level during the creation of tables through syncdb and at the model level by automagically adding validators to the respective fields. The model validation works similar to how it works in trunk ie the full_clean method is called only on ModelForm's save. For every other case, the user is responsible for calling the full_clean method.
The project was developed as a part of Google Summer of Code 2007 but due to the lack of model validation could not make much progress then. But with model validation making it in django v1.2, the project has been resurrected. The idea for the project was given by Kenneth Gonsalves and was mentored by Simon Blanchard.
Patch your django code with the django_check_constraints.diff file:
$ git apply django_check_constraints.diff
Add the check_constraints app anywhere on your PYTHONPATH or just add it into your project directory and reference it in the INSTALLED_APPS.
Run the check constraint test suite to figure if everything went well:
$ python manage.py test check_constraints
- Check out http://code.google.com/p/django-check-constraints/wiki/Features for the features of django check constraints.