title: How to access to a Many to Many object to get another model property?
body: <p>I'm coding a tooltip for a Django dashboard, so one of the scenarios says that when the user has not connected their Github account the repository link will be disabled. I already solved the problem but I didn't realized that it only works for the owner of the repo, so if I add somebody else as a collaborator, the link is going to work for them, because ofc, they are not the owners. </p>
  
  <p>models.py </p>
  
  <pre><code>class Project(models.Model):
      owner = models.ForeignKey(
          TeamMember,
          related_name="github_repos",
          blank=True,
          null=True,
          on_delete=models.SET_NULL,
      )
  
      members = models.ManyToManyField(
          TeamMember,
          related_name="new_projects",
          blank=True,
          through=ProjectMember,
      )
  
  class TeamMember(models.Model):
      class Meta:
          unique_together = ("team", "user_id")
  
      django_user = models.OneToOneField(
          settings.AUTH_USER_MODEL,
          related_name="team_member",
          null=True,
          on_delete=models.SET_NULL,
      )
      team = models.ForeignKey(
          Team, related_name="members", on_delete=models.SET_NULL, null=True
      )
      github_username = models.CharField(max_length=100, blank=True)
  </code></pre>
  
  <p>So basically how I solved the problem was this way:</p>
  
  <pre><code>    def html_message(self):
          pattern = re.compile("Github Repository", re.IGNORECASE)
  
          if self.project.owner.has_connected_github:
              git_connection = self.project.owner.django_user.socialaccount_set.filter(
                  provider="github"
              ).first()
              if git_connection:
                  html_message = pattern.sub(
                      f"&lt;a href='{self.project.html_url}'&gt;Github Repository&lt;/a&gt;", self.message
                  )
              else:
                  html_message = pattern.sub(
                      f"&lt;a href='#' data-toggle='tooltip' title='Connect your Github account to access repository.'&gt;Github Repository&lt;/a&gt;", self.message
                  ) 
  </code></pre>
  
  <p>That works but as I said before, only for the owner of the app, I need to know how to access to <code>members</code>, instead of <code>owner</code>, because as you can see is a Many to Many Field.</p>
  
  <p>Any idea how can I access it? I saw similar questions but I don't fully understand them.</p>