1👍
✅
You can use __isnull
to filter all outcomes that have a related Programme.
outcomes = Outcome.objects.filter(outcome_programme__isnull=False)
If more than one programme can have the same outcome, you might need to use distinct()
to prevent duplicates.
outcomes = Outcome.objects.filter(programme__isnull=False).distinct()
Source:stackexchange.com