【发布时间】:2016-03-19 22:41:26
【问题描述】:
当我对我的一个项目应用程序执行迁移时,我收到以下错误:
ValueError:模型的未处理挂起操作: common.shipmentaddress(字段引用:catalog.Fulfillment.address)
Django 1.9,python 2.7.10
我一直在寻找循环导入,但我认为不是这样
这些是模型:
class ShipmentAddress(models.Model):
recipient_first_name = models.CharField(max_length=50, null=True, blank=True)
recipient_last_name = models.CharField(max_length=50, null=True, blank=True)
street_name = models.CharField(max_length=50)
state = models.ForeignKey(State)
postal_code = models.IntegerField(default=0)
city = models.CharField(max_length=50)
class Meta:
db_table = 'shipment_address'
class Fulfillment(models.Model):
address = models.ForeignKey(ShipmentAddress)
inventory_items = models.ManyToManyField(Item_With_Size, through='Inventory_Item')
class Meta:
verbose_name = 'fulfilment'
verbose_name_plural = 'fulfilments'
db_table = 'fulfilment'
迁移看起来像这样:
class Migration(migrations.Migration):
dependencies = [
('catalog', '0009_auto_20151130_1118'),
]
operations = [
migrations.AlterField(
model_name='fulfillment',
name='address',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='common.ShipmentAddress'),
),
]
class Migration(migrations.Migration):
dependencies = [
('common', '0005_shipmentaddress'),
]
operations = [
migrations.RenameField(
model_name='shipmentaddress',
old_name='recipient_name',
new_name='recipient_first_name',
),
migrations.AddField(
model_name='shipmentaddress',
name='recipient_last_name',
field=models.CharField(blank=True, max_length=50, null=True),
),
]
【问题讨论】:
-
你能发布有问题的模型定义吗?
-
您能否发布
common和catalog应用程序的迁移以及完整的回溯? -
我编辑了我所做的实际迁移是在其他应用程序上的问题(以上都不是)
标签: python django django-models database-migration django-1.9