假设我有这些基本模型:
class Trackable(PolymorphicModel):
uuid = UUIDField(unique=True)
created_by = models.ForeignKey(settings.AUTH_USER_MODEL)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
Run Code Online (Sandbox Code Playgroud)
儿童模型扩展了它:
class Like(Trackable):
content = models.ForeignKey(Content, related_name='likes')
class Meta:
unique_together = ['content', 'created_by']
Run Code Online (Sandbox Code Playgroud)
当我运行迁移时,它抱怨:
django.db.models.fields.FieldDoesNotExist: Like has no field named u'created_by'
Run Code Online (Sandbox Code Playgroud)