我正在尝试在Django 1.8中进行迁移。关系“org_user_orguser”不存在
迁移看起来是这样的:
# -*- 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 = "[email protected]"
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
但是绝对有一个org_user的模型,它在我的settings.py中。
这里我的迁移究竟发生了什么?如何成功运行此迁移中列出的更改?
这是在Postgres,如果有帮助。
编辑:
当我暂时删除的迁移,并重新创建数据库,一切都建立精细(包括org_user),如果我再尝试添加迁移回模型/迁移目录并运行它,我得到的错误:LookupError: No installed app with label 'org_user'.
'org_user.0001_initial'迁移的内容是什么?迁移失败的名称是什么?如果你也展示OrgUser模型,它可能会有所帮助。'关系不存在'错误并不意味着该模型尚未定义,这意味着该表尚未在您的数据库中创建。关于[此票证]的注释(https://code.djangoproject.com/ticket/22932#comment:4)可能会帮助您解决循环依存关系错误。 – Alasdair
请显示所有模型 – Pynchia
org_user.0001_initial迁移是上面的迁移 - 它位于/org_user/migration/0001_initial.py。你只想要模型,@ pynchia?有十个。 –