Tuesday, May 31, 2011

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

On Mon, May 30, 2011 at 09:52:27PM -0700, Gchorn wrote:
> 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

Use South (http://south.aeracode.org/).

Or you can run ./manage.py dbshell, and ALTER TABLE yourself, for
example, for PostgreSQL::

ALTER TABLE <app_model> ALTER COLUMN <col> DROP NOT NULL;

--
Kirill Spitsin

--
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