首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Django南迁移错误

Django南迁移错误
EN

Stack Overflow用户
提问于 2012-08-09 19:37:58
回答 3查看 4.2K关注 0票数 9

我在尝试应用第一个南迁移时遇到错误。我尝试过各种建议(比如删除迁移文件夹中的.pyc文件,转换应用程序并尝试重新启动它,等等)。在座的各位能给我提个建议吗?谢谢

代码语言:javascript
运行
复制
(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'
EN

回答 3

Stack Overflow用户

发布于 2013-03-13 11:55:35

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

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

票数 17
EN

Stack Overflow用户

发布于 2013-01-24 22:34:22

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

票数 3
EN

Stack Overflow用户

发布于 2019-01-11 04:10:53

哇。我得到了AttributeError:'module‘对象没有属性’迁移‘错误,原因与上面的答案完全不同。

我有一个缩进错误的迁移文件:

代码语言:javascript
运行
复制
class Migration(SchemaMigration):
    def forwards(self, orm):
        # 

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

而不是...

代码语言:javascript
运行
复制
class Migration(SchemaMigration):
    def forwards(self, orm):
        # 

    def backwards(self, orm):
        # 

    models = {...}

我不知道为什么我会有这样的错误,但是当我修复了这个错误之后。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11882554

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档