【发布时间】:2016-01-24 15:41:29
【问题描述】:
拥有此代码:
class Part:
name = models.CharField(
_("Name of part"),
max_length=255,
help_text=_("Name of the part.")
class Meta:
verbose_name = _("Part")
verbose_name_plural = _("Parts")
abstract = True
class Book(Part):
isbn = models.CharField(
help_text=_("The ISBN of the book"),
max_length=15
)
对于我的模型。下一步我需要链接到基本对象。完成此代码:
class StorageItem(models.Model):
part = models.ForeignKey(
Part,
help_text=_("The part stored at this spot.")
)
我收到此错误消息:
错误:StorageItem.part:(fields.E300)字段定义 与模型“零件”的关系,该模型要么未安装,要么已安装 摘要。
将一个对象链接到一组不同类的正确方法是什么?这些类都派生自一个基类?
【问题讨论】:
标签: python django class inheritance django-models