Django 编程错误:多次指定列

Django 编程错误:多次指定列,django,django-models,Django,Django Models,我正在django项目中尝试运行'syncdb-all',刚刚添加了这个模型 但是,我收到以下错误消息: django.db.utils.ProgrammingError: column "target_content_type_id" specified more than once 为什么在“目标内容类型id”不重复且不在任何其他模型中时会发生这种情况 class Action(models.Model): actor = models.ForeignKey(User) v

我正在django项目中尝试运行'syncdb-all',刚刚添加了这个模型

但是,我收到以下错误消息:

django.db.utils.ProgrammingError: column "target_content_type_id" specified more than once
为什么在“目标内容类型id”不重复且不在任何其他模型中时会发生这种情况

class Action(models.Model):
    actor = models.ForeignKey(User)
    verb = models.CharField(max_length=500)
    action_object_content_type = models.ForeignKey(
        ContentType, related_name='action_object', blank=True, null=True
    )
    action_object_object_id = models.CharField(
        max_length=500, blank=True, null=True
    )
    action_object = generic.GenericForeignKey(
        'action_object_content_type', 'action_object_object_id'
    )
    target_content_type = models.ForeignKey(
        ContentType, related_name='target', blank=True, null=True
    )
    target_content_type_id = models.CharField(
        max_length=500, blank=True, null=True
    )
    target = generic.GenericForeignKey(
        'target_content_type', 'target_content_type_id'
    )

    public = models.BooleanField(default=True)
    timestamp = models.DateTimeField(auto_now_add=True)

在幕后指定
ForeignKey
字段时,Django会在字段名后面附加
“\u id”
,以创建其数据库列名

在这种情况下,您的字段
target\u content\u type
是一个
ForeignKey
,它将对应于数据库列
target\u content\u type\u id
,它与您的charfield冲突

将您的
target\u content\u type\u id
重命名为类似
target\u content\u type\u object\u id
或唯一的名称

这是一个和更多