gpt4 book ai didi

Django 多态模型在 1.7 上存在迁移问题

转载 作者:行者123 更新时间:2023-12-03 10:25:43 27 4
gpt4 key购买 nike

我正在为我的模型使用 Django 1.7 和 django-polymorphic

class ReferenceItem(PolymorphicModel):
created_at = models.DateTimeField(_('date created'), auto_now_add=True, db_index=True)
updated_at = models.DateTimeField(_('date modified'), auto_now=True, db_index=True)
uuid = UUIDField(auto=True, unique=True)
description = models.CharField(max_length=255)

class OrderItem(ReferenceItem):
order = models.ForeignKey('Order', related_name='items')
sku = models.CharField(max_length=255)
quantity = models.IntegerField()
unit_price = models.DecimalField(max_digits=10, decimal_places=2)
amount = models.DecimalField(max_digits=10, decimal_places=2)
tax_rate = models.DecimalField(max_digits=3, decimal_places=2)
commission_rate = models.DecimalField(max_digits=3, decimal_places=2)

当我运行 makemigrations 时出现此错误:

raise InvalidBasesError("Cannot resolve bases for %r\nThis can happen if you are inheriting models from an app with migrations (e.g. contrib.auth)\n in an app with no migrations; see https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies for more" % new_unrendered_models)
django.db.migrations.state.InvalidBasesError: Cannot resolve bases for [<ModelState: 'orders.OrderItem'>]
This can happen if you are inheriting models from an app with migrations (e.g. contrib.auth)

我已经通过 django ticket但仍然不知道问题出在哪里。

最佳答案

我猜这与多态包无关。

我所做的修复它是注释掉我的应用程序,留下内置的 django 应用程序,运行 ./manage.py migrate 来迁移系统应用程序,然后取消注释我的应用程序,然后运行./manage.py makemigrations

关于Django 多态模型在 1.7 上存在迁移问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25857169/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com