Django for ISchoolers: Difference between revisions
Content added Content deleted
imported>Aldeka |
imported>Aldeka |
||
Line 715: | Line 715: | ||
$ python manage.py schemamigration qandabear --auto |
$ python manage.py schemamigration qandabear --auto |
||
</code> |
</code> |
||
You should get a warning message that looks like this: |
|||
<code> |
|||
? The field 'Question.pub_date' does not have a default specified, yet is NOT NULL. |
|||
? Since you are removing 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 |
|||
? 3. Disable the backwards migration by raising an exception. |
|||
</code> |
|||
South insists on having a default value for this field just in case, even though we're about to remove it. So, let's do that. Enter '2'. |
|||
<code> |
|||
? Please enter Python code for your one-off default value. |
|||
? The datetime module is available, so you can do e.g. datetime.date.today() |
|||
</code> |
|||
pub_date is supposed to be a date of some kind. The default may as well be today! |
|||
<code> |
|||
? Please enter Python code for your one-off default value. |
|||
? The datetime module is available, so you can do e.g. datetime.date.today() |
|||
>>> datetime.date.today() |
|||
</code> |
|||
South will then happily finish creating your migration. |
|||
* Apply the migration. |
* Apply the migration. |
||
Line 720: | Line 748: | ||
<code> |
<code> |
||
$ python manage.py migrate qandabear |
$ python manage.py migrate qandabear |
||
Running migrations for qandabear: |
|||
- Migrating forwards to 0002_auto__add_field_answer_votes__del_field_question_pub_date. |
|||
> qandabear:0002_auto__add_field_answer_votes__del_field_question_pub_date |
|||
- Loading initial data for qandabear. |
|||
No fixtures found. |
|||
</code> |
</code> |
||
Success! |
|||
===Save and commit=== |
===Save and commit=== |