使用postgres时出现Django泛型关系错误

2024-03-28 08:48:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我在Django的模型有泛型关系,我使用postgres作为我的数据库。 这是我的模特

Reaction(models.Model):
    object_id = models.TextField(_('object ID'))
    root_obj = GenericForeignKey(ct_field="content_type", fk_field="object_id")
    react = models.CharField('Reaction', max_length=10)


class Blog(models.Model):
    headline = models.TextField('headline')
    data = GenericRelation(Reaction)

当我被一般关系过滤时(例如。Blog.objects.filter文件(react\uuu data=XX))我得到了这个错误:

operator does not exist: integer = text
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

我认为有一个在这个链接修复,但我不知道该怎么办。 https://code.djangoproject.com/ticket/16055

谢谢!你知道吗


Tags: djangoidfielddatamodelobject关系models