Reputation: 1171
I have an existing Django project in version 1.5, and now I've upgraded it to the new Django 1.7.
My main concern is about migrations.
I took the following steps to convert my project to Django 1.7.
south_migrations
folder./manage.py makemigrations
./manage.py migrate
Is this the correct approach?
I have another issue. When I run ./manage.py runserver
it gives warnings like this:
HINT: Django 1.6 changed the default value of BooleanField from False to None. See https://docs.djangoproject.com/en/1.6/ref/models/fields/#booleanfield for more information. sqls.Sql.updates: (1_6.W002) BooleanField does not have a default value.
How can I fix this? I just put in a default value for BooleanField
, then ran makemigrations
and migrate
. Is that enough or do I need to do something more?
Upvotes: 4
Views: 2121
Reputation: 49092
My main concern is about migrations. Is this the correct approach?
Yes. If all of your deployments are up to date (that is, there are no South migrations that haven't been applied), you can simply delete the South migrations and remove South from INSTALLED_APPS
. From Django's perspective you are taking an existing app and converting it to use migrations, a straightforward case described in the documentation:
If your app already has models and database tables, and doesn’t have migrations yet (for example, you created it against a previous Django version), you’ll need to convert it to use migrations; this is a simple process:
$ python manage.py makemigrations your_app_label
This will make a new initial migration for your app. Now, when you run migrate, Django will detect that you have an initial migration and that the tables it wants to create already exist, and will mark the migration as already applied.
How can I fix these BooleanField
warnings?
(Note that this warning no longer exists as of Django 1.8.)
Those warnings refer to a backwards-incompatible change in Django that might affect you. But it probably doesn't. It would only affect you if your code didn't specify a default value for a BooleanField
, but still expected it to use the default value of False
. You should look at all the BooleanFields
in all your apps and decide if that is ever the case.
If not, you can simply silence the warning using the SILENCED_SYSTEM_CHECKS
setting.
If your code does rely on this implicit default value, then, after converting the app to use migrations, you should add the default=False
explicitly and create a migration. (Of course, you could just do that everywhere anyway, but it's better not to define a default value if you don't actually need to use one.)
Upvotes: 3