1👍
✅
Your question is hard to understand, so I’ll look at a couple of interpretations:
-
You want to get countries for a particular post:
countries = Country.objects.filter(post=post_instance)
-
You want to get all countries that have any posts:
countries = Country.objects.filter(post__isnull=False)
Similarly, if you wanted to get countries that don’t have a post associated with them:
countries = Country.objects.filter(post__isnull=True)
Source:stackexchange.com