For simplicity, let's assume we have a model A and model B.
class A(models.Model):
name = models.CharField(max_length=200)
class B(models.Model):
a = models.ForeignKey(A)
criteria = models.BooleanField(default = False)
Let's say there's a requirement to find A that doesn't have a B with a true criteria. To me, it makes more sense to use a "not exists" subquery. Right now, I have to find all the A with the reverse conditions and exclude such cases. Something like:
A.objects.exclude(pk__in = A.objects.filter(b__criteria = True))
The problem with this approach is that: first I don't know how the performance would be; second, it's not very natural from sql query's perspective.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/19f716f4-2367-492c-ac1e-a4f48c4a2c01%40googlegroups.com.