I'm using django 1.7 for my application. I came across several problems with migrate. Everytime I try to change a field name in models which is a foreign key, it breaks. The only fix would be to go to database and fix it, and they run migrate
followed by syncdb
.
How do I solve these as my application is turning bigger, and i'll soon be spending more time in resolving the database errors as my schema changes.
South is not supported for django 1.7 and has its own migration which is not powerful?(I'm not sure, just a beginner)

- 1,164
- 3
- 15
- 34
-
1What makes you think Django's built-in migrations are not as powerful? On the contrary, they are significantly more powerful: the author of South wrote the new functionality, and it is tightly integrated with Django. – Daniel Roseman Oct 08 '14 at 19:54
-
I did go through the docs. But it breaks when I try to change the foreign key name, and every now and then I have to go and fix it manually in mysql. – theblackpearl Oct 08 '14 at 23:39
-
Are you perchance using a `default=callback_function` for the `ForeignKey`? like.... `parent = models.ForeignKey('Parent', default=get_parent, null=False)` – pztrick Oct 09 '14 at 01:00
1 Answers
The migration framework in Django 1.7 is based on South. I you are upgrading you should read this:
https://docs.djangoproject.com/en/1.7/topics/migrations/#upgrading-from-south
from the docs:
Upgrading from South If you already have pre-existing migrations created with South, then the upgrade process to use django.db.migrations is quite simple:
Ensure all installs are fully up-to-date with their migrations. Remove 'south' from INSTALLED_APPS. Delete all your (numbered) migration files, but not the directory or init.py - make sure you remove the .pyc files too. Run python manage.py makemigrations. Django should see the empty migration directories and make new initial migrations in the new format. Run python manage.py migrate. Django will see that the tables for the initial migrations already exist and mark them as applied without running them. That’s it! The only complication is if you have a circular dependency loop of foreign keys; in this case, makemigrations might make more than one initial migration, and you’ll need to mark them all as applied using:
python manage.py migrate --fake yourappnamehere

- 1,053
- 3
- 12
- 21

- 1,182
- 1
- 11
- 26
-
I do not have any applications with earlier django versions. I've it on 1.7, the question was what could i do to solve the problems i face with migrations, as using south is not an option for django 1.7 – theblackpearl Oct 08 '14 at 23:38
-
Just a note that if you're going to higher than 1.7, the docs say to run "manage.py migrate", but you'll need to run "manage.py migrate --fake-initial". In 1.7, --fake-initial was the default, and then it got dropped later. – theicfire Feb 10 '17 at 02:16