Ask Your Question
1

ValueError: The database backend does not accept 0 as a value for AutoField.

asked 2013-11-21 07:50:57 -0600

Nikhil gravatar image

updated 2013-11-21 08:30:10 -0600

I am seeing this error when I run "python manage.py migrate askbot" My database is MySQL and its version is "Server version: 5.5.34-0ubuntu0.12.04.1"

I set up mysql using :

  1. sudo apt-get install build-essential
  2. python-dev libmysqlclient-dev sudo
  3. pip install mysql-python
  4. sudo apt-get install python-mysqldb
  5. sudo apt-get install mysql-server

I tried:

  1. python manage.py migrate askbot 0054 #migrate normally up to the 54th migration
  2. python manage.py migrate askbot 0055 --fake #skip this migration
  3. python manage.py migrate askbot #finish migrating askbot
  4. python manage.py migrate #finish migrating anything else (if necessary)

But I got error at #89, #92 and #98

edit retag flag offensive close merge delete

Comments

I've made some changes in the migrations and was able to install with mysql without errors. However, I have not seen errors that you did.

Evgeny gravatar imageEvgeny ( 2013-11-25 14:28:59 -0600 )edit

I'm experiencing the same problem. It seems there's a problem in the migration files. The following StackOverflow post suggest to remove the default value for foreign keys: http://stackoverflow.com/questions/15169001/south-raises-valueerror-when-trying-to-migrate If you want to keep the default value it seems you can still use None instead of 0 or False: http://rpki.net/ticket/607 It would be great if you could fix this. Thanks a lot!

Michel Krämer gravatar imageMichel Krämer ( 2013-11-28 10:25:17 -0600 )edit

I just tested this and it works indeed. I had to edit the following migrations: 0055,0080,0093,0099 (two lines)

Michel Krämer gravatar imageMichel Krämer ( 2013-11-28 10:44:17 -0600 )edit

I have raised a pull request that fixes this issue but it hasn't been merged yet: https://github.com/ASKBOT/askbot-devel/pull/207%3C/p (https://github.com/ASKBOT/askbot-devel/pull/207</p<>>)

Francis Devereux gravatar imageFrancis Devereux ( 2014-04-23 06:34:00 -0600 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2014-03-31 09:06:28 -0600

tmonteil gravatar image

I had the same problem. Four migration scripts set 0 as a default value for ForeignKey, which seems not accepted. Instead, you can set None as the default value. The following changes in the migrations script should fix this problem:

  • go to the askbot/migrations directory
  • type:

    sed -i.old 's|\(ForeignKey.*\)default=0|\1default=None|g' 0055_*.py 0080_*.py 0093_*.py 0099_*.py

edit flag offensive delete link more

Comments

1

This worked for me

alexsf gravatar imagealexsf ( 2014-07-28 13:18:05 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-11-21 07:50:57 -0600

Seen: 6,411 times

Last updated: Mar 31 '14