【问题标题】:South Migration Error南移错误
【发布时间】:2013-11-17 04:32:02
【问题描述】:

我正在尝试通过设置我在 github 上找到的项目之一来学习 Django。之后我运行了它显示的 syncdb 命令 未同步(使用迁移): - django_extensions - djangoatings - 配置文件 - 监护人 (使用 ./manage.py migrate 迁移这些)。

当我运行“python manage.py migrate app”时,它给出了 AttributeError:“模块”对象没有“迁移”属性。

我还运行了 schemamigration app --auto 和 --initial。但似乎没有任何效果。谁能指出我哪里出错了。

【问题讨论】:

  • 如果您刚刚开始,请删除您的迁移目录,然后运行您的 schemamigration --initial,然后运行 ​​syncdb。
  • @ZackArgyle ,当我运行时---->python manage.py schemamigration profiles --initial 在 '\profiles\migrations' 处创建迁移目录... 创建 init .py in '\profiles\migrations'... + 添加了模型profiles.Project + 添加了模型profiles.UserProfile + 添加了模型profiles.SavedResource + 在profiles.SavedResource 上添加了['user', 'resource'] 的唯一约束 + 添加模型profiles.TopicFollow + 在profiles.TopicFollow Created 0001_initial.py 上为['user', 'topic'] 添加了唯一约束。您现在可以通过以下方式应用此迁移:./manage.py migrate profiles
  • @ZackArgyle: 但是下一个命令给出了同样的错误,当我运行时----->python manage.py migrate profile es AttributeError: 'module' object has no attribute 'Migration'跨度>
  • syncdb 在你迁移之前,在 schemamigration --initial 之后
  • @ZackArgyle:我当然这样做了 :)

标签: python django django-south


【解决方案1】:

你真的在运行python manage.py migrate app吗?如果要迁移所有应用程序,只需运行 python manage.py migrate。 (没有app)如果有一个实际名为app 的应用程序您要为其运行迁移,那么您将按照您的方式进行操作。

如果运行python manage.py migrate后仍然报错,那么一定是某处存在无效的迁移文件。我会像这样单独迁移每个应用程序:

python manage.py migrate django_extensions
python manage.py migrate djangoratings
... etc.

查找迁移文件错误的应用。找到应用后,查看应用的迁移文件夹以找到任何空的迁移文件。

【讨论】:

    【解决方案2】:

    首先必须运行初始迁移。

    python manage.py schemamigration --initial

    您收到此错误是因为您的项目结构,或者您的 south 软件包存在问题。请尝试删除并重新安装 south。
    您需要查看迁移文件夹中不应有任何额外的 .py 文件。

    【讨论】:

    • 我重新安装了南并从迁移中删除了所有 .py 和 .pyc 文件,但我仍然遇到同样的错误。
    猜你喜欢
    • 2011-11-19
    • 2011-02-20
    • 2014-06-26
    • 2013-02-04
    • 2013-02-09
    • 2016-10-27
    • 2014-03-21
    • 1970-01-01
    • 2015-04-28
    相关资源
    最近更新 更多