Search code examples
pythondjangodjango-1.4

Django: cannot import name migrations


I had an issue I just posted here. I saw an answer to a similar question which said uninstalling and installing requirements.txt would help because the root of the issue was a bad dependency chain.

So I did that and now, of course, I ran into a new issue.

When running the migrations, I am getting the following error:

  File "C:\Python27\lib\site-packages\genericm2m\migrations\0001_initial.py", line 5, in <module>
    from django.db import migrations, models
ImportError: cannot import name migrations

According to another answer, this is caused because I am using the migrations module, which my Django version (1.4) doesn't support yet.

It seems like the django-generic-m2m module (version 0.3.1) is using migrations. I don't understand why this issue is happening now, as I have always used the same requirements.txt file and I never had this problem.

I used to have similar problems with dependencies using migrations while my Django couldn't handle them. But these deps also had a south_migrations folder, so just renaming it to migrations and getting rid of the actual migrations folder would do the trick. However, I don't see any south_migrations directory in the generic2m2 installation dir.

Has anybody had this issue before?


Solution

  • The app does not have South migrations, and as far as I can find, it never had them. It probably used to rely on 'syncdb' to create the database tables.

    Newer Django doesn't have syncdb, so migrations to create the tables were added.

    If you are used to renaming migrations directories anyway, then you could probably just remove the migrations/ directory, but you should really upgrade to a supported version.

    Also, your old fix of renaming south_migrations to migrations wasn't the intended use: if you use Django-South 1.0 (the last version of django-south ever), it will detect when a south_migrations directory is present and use it instead of the migrations directory.

    So you should also update South to 1.0, and then adding an empty south_migrations/ directory may also work (I don't know).