Sounds so simple, but has me stymied:
class A(models.Model):
various fields
class P(models.Model):
various fields
a = models.ForeignKey(A)
object_a = A.objects.get(pk=1)
p_objects = P.objects.filter(a=objecta) # one way
p_objects = A.p_set.all() # other way
to get all the P’s that belong object_a is easy. What I can’t figure out is how to get all the A objects that have no associated P object.
I can’t reverse the ForeignKey relation because each A might have more than one P.
This will work