Hi,
Lets say I have models like:
class A(models.Model):
pass
class B(models.Model):
t = models.CharField(max_length=100)
a = models.ForeignKey('A', related_name="bs")
I've found out, that the following query is working:
A.objects.filter(bs__t='1').filter(bs__t='2')
which returns those As that have at least one B with t='1' AND at
least one B with t='2'. The underlying query lokk like this:
SELECT "search_test_a"."id" FROM "search_test_a" INNER JOIN
"search_test_b" ON ("search_test_a"."id" = "search_test_b"."a_id")
INNER JOIN "search_test_b" T3 ON ("search_test_a"."id" = T3."a_id")
WHERE ("search_test_b"."t" = E'1' AND T3."t" = E'2' ) LIMIT 21
Now my question:
Is it an official feature? I can't find it anywhere in
documentation...
regards,
Filip
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---