9

I am getting an error trying to apply a first South migration. I have tried various suggestions (like removing .pyc files in the migrations folder, converting the app as well as trying to start it afresh, other fiddles). Can anyone here suggest what I might do? Thanks

(env)~/code/django/ssc/dev/ssc/ssc> python manage.py migrate
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/south/management/commands/migrate.py", line 108, in handle
    ignore_ghosts = ignore_ghosts,
  File "/usr/local/lib/python2.7/dist-packages/south/migration/__init__.py", line 166, in migrate_app
    Migrations.calculate_dependencies()
  File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 228, in calculate_dependencies
    migration.calculate_dependencies()
  File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 362, in calculate_dependencies
    for migration in self._get_dependency_objects("depends_on"):
  File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 342, in _get_dependency_objects
    for app, name in getattr(self.migration_class(), attrname, []):
  File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 314, in migration_class
    return self.migration().Migration
AttributeError: 'module' object has no attribute 'Migration'
(env)~/code/django/ssc/dev/ssc/ssc> python manage.py convert_to_south crewcal
This application is already managed by South.
(env)~/code/django/ssc/dev/ssc/ssc> python manage.py migrateTraceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/south/management/commands/migrate.py", line 108, in handle
    ignore_ghosts = ignore_ghosts,
  File "/usr/local/lib/python2.7/dist-packages/south/migration/__init__.py", line 166, in migrate_app
    Migrations.calculate_dependencies()
  File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 228, in calculate_dependencies
    migration.calculate_dependencies()
  File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 362, in calculate_dependencies
    for migration in self._get_dependency_objects("depends_on"):
  File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 342, in _get_dependency_objects
    for app, name in getattr(self.migration_class(), attrname, []):
  File "/usr/local/lib/python2.7/dist-packages/south/migration/base.py", line 314, in migration_class
    return self.migration().Migration
AttributeError: 'module' object has no attribute 'Migration'
5
  • Have you actually created the migration? python manage.py schemamigration --initial Commented Aug 9, 2012 at 11:49
  • Have you seen this: south.aeracode.org/ticket/819 Commented Aug 9, 2012 at 12:03
  • The code isn't failing on a particular migration or even a particular app -- it never gets that far. There's either something wrong with your South package or you've got some kind of off-the-wall project structure that's freaking it out. Try removing and reinstalling South, and if you're doing anything abnormal with how models or apps are laid out, note that in your question. Commented Aug 9, 2012 at 14:31
  • Stupid question (happens to me once): do you have the init.py file inside the migrations folder?
    – pyriku
    Commented Aug 9, 2012 at 15:55
  • Reinstalled again and it was fine. Matter of fiddling. Thanks for your attentions.
    – KindOfGuy
    Commented Aug 9, 2012 at 16:28

3 Answers 3

17

In my case the AttributeError: 'module' object has no attribute 'Migration' error was simply a matter of having an extra .py file in my migrations folder.

I had an extra utilities module in my migrations directory which caused South to choke. Moving the module into a different directory (above my apps migrations directory) solved the problem for me.

2
  • randlet, yes you are right, there was extra .py file in migrations folder, I deleted them and now its working fine.
    – Shariq
    Commented Dec 31, 2013 at 5:11
  • In my case i had an init.py file in my migrations folder I just deleted
    – Tim
    Commented Sep 29, 2014 at 20:45
3

Maybe a bit late, but still... Is it possible you have any other package (folder with __init__.py) in your migration package and it interferes with the structure?

1
  • I did scp hostname:/remote/path/to/app/migrations /local/path/to/app/migrations/. Then I did it again after adding some migrations, except that this time, because migrations folder existed, scp put the second copy inside.
    – Aalex Gabi
    Commented Feb 14, 2013 at 10:07
0

Wow. I was getting the AttributeError: 'module' object has no attribute 'Migration' error for a completely different reason than the above answers.

I had a migration file which had a bad indent:

class Migration(SchemaMigration):
    def forwards(self, orm):
        # 

    def backwards(self, orm):
        # 
        models = {...}

As opposed to ...

class Migration(SchemaMigration):
    def forwards(self, orm):
        # 

    def backwards(self, orm):
        # 

    models = {...}

I don't know why I had that but when I fixed that the error was gone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.