我正在尝试在django1.8中进行迁移。你知道吗
迁移过程如下所示:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
def update_email_username(apps, schema_editor):
user_id = 'the-uuid-will-go-here'
OrgUser = apps.get_model("org_user", "OrgUser")
for person in OrgUser.objects.filter(user_id=user_id):
person.username = "person@email.com"
person.save()
class Migration(migrations.Migration):
dependencies = [
('org_user', '0001_initial'),
]
operations = [
migrations.RunPython(update_email_username),
]
我得到:
django.db.migrations.graph.CircularDependencyError: org_user.0001_initial
我也试过了
dependencies = [
('org_user', '__first__'),
]
我得到:
django.db.utils.ProgrammingError: relation "org_user_orguser" does not exist
但绝对有一个组织用户模型,这是在我的设置.py. 你知道吗
我的移民到底是怎么回事?如何成功运行此迁移中列出的更改?你知道吗
如果有帮助的话,这是在Postgres中。你知道吗
编辑:
当我临时删除迁移并重新创建数据库时,一切都正常(包括org\u user),如果我尝试将迁移添加回模型的/migration目录并运行它,我会得到错误:LookupError: No installed app with label 'org_user'.
我真的不知道,如果我理解正确的话。。。 通常,从一个新的项目开始,它是这样工作的:
manage.py makemigrations
manage.py makemigrations
,并且会在migrations文件夹中自动创建一个新的迁移。你知道吗如果您有多个包,则自动生成的迁移通常都将每个包的最后一次迁移作为依赖项。如果您不想执行任何数据迁移或其他操作,就不需要关心依赖关系。你知道吗
您可以找到更多信息here
初始迁移应该始终使用
命令
编辑:您确定不想要:
什么?你知道吗
相关问题 更多 >
编程相关推荐