1

I have a class Image with the following GenericRelation:

properties = models.GenericRelation(Property)

I'm trying to get all Images with certain properties, so I do this:

Image.objects.filter(properties__type = "foo", properties__user = request.user)

But this results in the following error:

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.

Is it not possible to query that way? What can I do as an alternative?

Salvatore Iovene
  • 2,064
  • 1
  • 17
  • 31
  • you gave a peace of error ; we could give you a peace of answer in that case but not sure that works ;) you should show us the 2 models too –  Oct 18 '13 at 07:25

1 Answers1

0

If you need to do very complex queries over generic relations, then i would rather suggest you write the sql yourself and use raw queries rather. So i guess i would say raw query is an alternative.

Odif Yltsaeb
  • 5,575
  • 12
  • 49
  • 80