SilentDev
SilentDev

Reputation: 22747

south schemamigration asking for 'one-off value' when trying to mirgate app

okay so I had an app and I wanted to convert it to south (if that's the right terminology). I wanted to do this because I had a model and I did

python manage.py syncdb

and then I made changes to the model and then it didn't let me syncdb. After doing some changes, I figured out that using south was the solution. SO I put south in my installed apps then I did

python manage.py syncdb

and got south installed. Then, following the instructions on www.djangopro.com/2011/01/django-database-migration-tool-south-explained/ , I then did

manage.py convert_to_south myapp 

to create the migration file for generation 1 and also to create the migrationhistory entry, which worked. Next, I did

manage.py schemamigration myapp --auto

and it said

 ? The field 'Users.date_of_birth' does not have a default specified, yet is NOT NULL.
 ? Since you are adding this field, you MUST specify a default
 ? value to use for existing rows. Would you like to:
 ?  1. Quit now, and add a default to the field in models.py
 ?  2. Specify a one-off value to use for existing columns now
 ? Please select a choice: 2
 ? Please enter Python code for your one-off default value.
 ? The datetime module is available, so you can do e.g. datetime.date.today()
 >>> 

What does this mean? Am I doing something wrong? WHat value should I put for the on-off default value?

When I look at this website: south.readthedocs.org/en/latest/tutorial/part3.html , I see that when they used the schemamigration --auto and migrate on the app called southtut, it did not ask for the one-off default value at the beginning so I'm guessing I am doing something wrong. Any ideas?

Upvotes: 1

Views: 1555

Answers (1)

Aamir Rind
Aamir Rind

Reputation: 39659

No everything is fine. You have Users.date_of_birth field which does not have default value specified in the model e.g. default=datetime.now(), so that is why it is asking to specify the default value for the migration for older entries.

After step two when it says:

The datetime module is available, so you can do e.g. datetime.date.today()

Just do datetime.date.today() and press enter or choose any default date for the date_of_birth field.

Upvotes: 2

Related Questions