Ask Your Question

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

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

Nikhil gravatar image

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

I am seeing this error when I run "python 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 migrate askbot 0054 #migrate normally up to the 54th migration
  2. python migrate askbot 0055 --fake #skip this migration
  3. python migrate askbot #finish migrating askbot
  4. python migrate #finish migrating anything else (if necessary)

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

edit retag flag offensive close merge delete


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 -0500 )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: If you want to keep the default value it seems you can still use None instead of 0 or False: 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 -0500 )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 -0500 )edit

I have raised a pull request that fixes this issue but it hasn't been merged yet: (</p<>>)

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

1 Answer

Sort by » oldest newest most voted

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

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



This worked for me

alexsf gravatar imagealexsf ( 2014-07-28 13:18:05 -0500 )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


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

Seen: 7,140 times

Last updated: Mar 31 '14