0

Using Django 1.4 in my app I defined a model called Member and another called Data.Every member has basic like ID and it is related to a Data object that contains additional variables describing the "member".

I had initially created the member model without specifying that the dob variable could be NULL. I have since then changed this to allow for blank or null but I was still getting the members_data.dob may not be NULL error.

I thought it was because I needed to run a syncdb command, which I did, however this did not fix the problem.

dob = models.CharField(max_length=200, blank=True, null=True)

Any ideas? Thanks

ps. If you want to get an overall picture of what I am trying to implement please refer to: Can I use JSON data to add new objects in Django?

Thanks so much.

Community
  • 1
  • 1
BluePython
  • 1,635
  • 3
  • 24
  • 35

1 Answers1

1

The syncdb command only creates tables if they do not exist. It does not handle migrations for you. You have a few options:

  1. If there is no important data in the table, drop the table and run syncdb again to recreate it.
  2. Update the column to allow null in a db shell. The correct command depends on which database you are using.
  3. Use a migration tool, like South.

To drop the table in sqlite:

Open a dbshell

./manage.py dbshell

Drop the table

drop table <tablename>
Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • Thanks! Ok that was my question. I wasn't sure if this would signify I need a migration. So pretty much syncdb just creates the database tables, any other changes to it will require migration, no exception, right? – BluePython Sep 12 '13 at 07:07
  • I am using SQLite. Any ideas how can I drop the table since I dont have too much information in it and would also like to know how to do it in the shell in case I need it in the future. Thanks so much. – BluePython Sep 12 '13 at 07:09
  • I've added instructions to drop the table. See [this question](http://stackoverflow.com/questions/4007014/alter-column-in-sqlite) about altering columns in sqlite. – Alasdair Sep 12 '13 at 07:27