Django South AttributeError Migration

I suffer from this error when porting South (0.7.5) to Django (1.4). I recently changed the setting of Timezone to false, i.e. USE_TZ = False, to fix another problem. Any ideas? Thanks

~/code/django/ssc/dev/ssc/ssc: python manage.py migrate crewcal Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line utility.execute() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv self.execute(*args, **options.__dict__) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute output = self.handle(*args, **options) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/south/management/commands/migrate.py", line 105, in handle ignore_ghosts = ignore_ghosts, File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/south/migration/__init__.py", line 158, in migrate_app Migrations.calculate_dependencies() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/south/migration/base.py", line 227, in calculate_dependencies migration.calculate_dependencies() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/south/migration/base.py", line 355, in calculate_dependencies for migration in self._get_dependency_objects("depends_on"): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/south/migration/base.py", line 335, in _get_dependency_objects for app, name in getattr(self.migration_class(), attrname, []): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/south/migration/base.py", line 307, in migration_class return self.migration().Migration AttributeError: 'module' object has no attribute 'Migration' ~/code/django/ssc/dev/ssc/ssc: 
+4
source share
2 answers

It may be too late, but I don't think this has anything to do with TZ.

Each migration file has an declaration like:

 class Migration(SchemaMigration): ... 

AttributeError comes from the fact that this migration class was not found.

Check if all of your migrations have one. Otherwise, provide more details.

+4
source

The second Augusto Men answer, indeed, the mistake is that the South cannot find the implementation of Migration in the migration module. This is a general Python error message:

 AttributeError: 'module' object has no attribute 'Migration' 

The error is called in south.migration.base , now on line 315 (version 0.8.4)

Debug printout

Unfortunately, python manage.py migrate does not tell you which file is affected. You can help yourself by adding the following code above line 315 to <your-virtualenv>/local/lib/python*/site-packages/south/migration/base.py . This will tell you which file you should work with.

 print('## MODULE: %s' % str(self.migration())) 

Special occasion

I had a special case where an AttributeError shown for migrations/<some_app>/__init__.py , which usually should be just an empty file. An empty file stops working after I added an empty model.py model to my application to trick Django into looking at my fixtures application folder (see How to download Django from all applications? ). I believe that this is actually a mistake of the South.

Decision

As stated above, find out which migration module is affected and just add an empty implementation of the Migration class to this file, for example:

 from south.v2 import SchemaMigration class Migration(SchemaMigration): def forwards(self, orm): pass def backwards(self, orm): pass 
+1
source

Source: https://habr.com/ru/post/1341969/


All Articles