Monday, May 30, 2011

Can I perform an "alter table" to remove a "not null" constraint?

It seems as though the default in Django when creating tables is to
place a constraint that doesn't allow null values (contrary to what
I've learned is the default for SQL in general). I have a model which
has a date attribute, and which I now want to be able to hold null
values, but when I tried doing this by adding 'null = True' and 'blank
= True' to the model's field options, Django generates a

model.date may not be NULL

error when I try to leave the field blank in the Django admin
interface. This suggests I need to change something about the
database, rather than the model, correct? If so, what is the SQL
syntax for doing this? My research online has only turned up how to
apply a "not-null" constraint on a database table when creating the
table, not how to remove a "not-null" constraint on a table after it's
been created. Thanks in advance for any help on this!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment