It's been a good week, I have been able to make quite some progress
(about the quality of work, you'll have to comment).
Here is the brief procedure that I adopted to implement Check
1) Created a Check field that inherits the Field Class and here I
wrote the various attributes and methods for it (like for cascading
check conditions etc). Currently this Check Field has been added in
the django.db.models.fields.__init__.py file (at the end) and I'll
move it onto a separate file soon.
2) All the SQL creation statements have been left to the management.py
(I haven't modified the code but only added my code in the
management.py). I have not added the SQL statements in the class
itself because of the discussion here
3) As of now, I have only tested the check constraints on Postgresql
database server (it might also work on SQLite). One small modification
that has to be done to get the constraints thing working is to add a
'CheckField' : None entry in the
The check constraints got added successfully (after a syncdb) but the
problem is when I go to the admin page and to the model's page in it,
I get an error (link for the error page here
http://thejaswi.puthraya.googlepages.com/error.html). This error
vanishes when I comment the check fields in the models.py. I don't
understand why the Check (pseudo) field is getting (trying to get)
rendered in the Admin section.
There is currently no way to verify that all of the CHECK constraints
are mutually exclusive. Care is required by the database designer.
(I don't think it is possible to implement it because Postgresql also
isn't sure of how this is to be handled.)
Presently I am placing the files (outside the Google Hosting) and will
upload them after I get comments and sanction from the group to go
django.db.models.fields.__init__.py --> http://thejaswi.puthraya.googlepages.com/__init__.py
Insert a line in django.db.backends.postgresql.creation.py -->
"CheckField" : None
The 'like','between','upper' and 'lower' constraints haven't been
implemented as yet. That would be in the next phase of this project.
The Project is hosted on http://code.google.com/p/django-check-constraints
Features page is http://code.google.com/p/django-check-constraints/wiki/Features
Waiting for some constructive criticism.
PS: The next time I'll add more documentation to my work. (Totally
neglected it...extremely sorry).