Below are my django models
class Member(models.Model):
first_name = models.CharField(_("First name"), max_length=256)
class Community(models.Model):
member = models.ForeignKey(
Member,
verbose_name=_("Member"),
on_delete=models.CASCADE,
)
name = models.ForeignKey(
CommunityName,
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="community",
verbose_name=_("Name"),
)
class CommunityName(models.Model):
name = models.CharField(_("name of community"), max_length=256)
how to query communities a member has been to without repeating community names a member has been to more than ones
A member can leave in a community or different communities at different point in time. To get all communities a member have stayed in.
m = Member.objects.get(id=1)
[http://m.community](https://t.co/6j6ECyK83l?amp=1)_set.all()
This gives me all communities a member belong to but I want to find all CommunityNames a member belong to. E.g A member have stayed in CommunityA, CommunityB and CommunityA at different point in time but CommunityNames a member belongs to are CommunityA and CommunityB. Any help finding CommunityName a member belongs to.