I have 2 models,
Bacon and Eggs that both have ForeignKey to Spam model.
I need to find out the Bacon’s that are not related to Eggs, currently I’m doint it in the following way:
objs = Bacon.objects.select_related.filter(somefilter=value)
for obj in objs:
if obj.spam.eggsspam.count():
continue
do_something()
I’m sure there must be a more optimal way?
Try: