Django南迁移错误

时间:2012-08-09 11:37:58

标签: django django-south

我在尝试应用第一次南迁移时遇到错误。我尝试了各种建议(比如在迁移文件夹中删除.pyc文件,转换应用程序以及尝试重新启动它,其他小提琴)。这里有人可以建议我做什么吗?感谢

(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'

3 个答案:

答案 0 :(得分:17)

在我的情况下, AttributeError:'module'对象没有属性'Migration'错误只是在我的迁移文件夹中有一个额外的.py文件。

我的迁移目录中有一个额外的实用程序模块导致南方阻塞。将模块移动到另一个目录(我的应用程序迁移目录上方)解决了我的问题。

答案 1 :(得分:3)

也许有点晚了,但还是...... 您的迁移包中是否有可能包含任何其他包(包含__init__.py的文件夹)并且它会干扰结构?

答案 2 :(得分:0)

哇。我得到的 AttributeError:'module'对象没有属性'Migration'错误,原因与上述答案完全不同。

我有一个缩进不好的迁移文件:

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

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

相对于...

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

    def backwards(self, orm):
        # 

    models = {...}

我不知道为什么要这么做,但是当我修正错误消失后。