我正在尝试在 Django 1.7 中添加初始数据,并且我读到建议使用数据迁移。
我已经正确创建了名为“0001_groups”的迁移文件,我在其中创建了几个contrib.auth
的组和权限。
问题是它在 auth
迁移运行之前运行。
我去查了一下last migration of the auth
app的名字是什么? ,它被称为 0005_alter_user_last_login_null.py
。所以我尝试了:
dependencies = [
('auth', '0005_alter_user_last_login_null'),
]
但我得到:
KeyError: u"Migration appname.0001_groups dependencies references nonexistent parent node ('auth', '0005_alter_user_last_login_null')"
我用谷歌搜索了那个错误,它总是链接到 11 个月前修复的 Django 错误。
如何正确指定 auth
应用依赖项?
最佳答案
我发现您可以使用 __latest__
引用上次迁移:
dependencies = [
('auth', '__latest__'),
]
关于python - 在迁移中指定应用程序依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25703414/