【发布时间】:2013-10-18 06:22:33
【问题描述】:
我有一个班级Image,下面是GenericRelation:
properties = models.GenericRelation(Property)
我正在尝试获取具有某些属性的所有图像,所以我这样做:
Image.objects.filter(properties__type = "foo", properties__user = request.user)
但这会导致以下错误:
DatabaseError: operator does not exist: integer = text
LINE 1: ...perties_property" ON ("myapp_image"."id" = "propert...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
不能这样查询吗?作为替代方案,我能做些什么?
【问题讨论】:
-
你给了一个和平的错误;在这种情况下,我们可以给您一个安心的答案,但不确定是否可行;)您也应该向我们展示这 2 个模型
标签: django django-orm generic-relations