title: How do i access the properties of a many-to-many with Membership in Django
body: <p>How can i set only mine membership, instead of all in for-loop ?</p>
  
  <p>template.html:</p>
  
  <pre><code>         {% for g in gr %}
  
             &lt;div class="jumbotron"&gt;
              &lt;div class="jumbo2"&gt;
                &lt;form method="POST" class="post-form"&gt; {% csrf_token %}
                  &lt;p id="name"&gt;&lt;b&gt;Groups name:&lt;/b&gt; {{g.name}}&lt;/p&gt;&lt;br&gt;
  
                  {% for membership in g.membership_set.all %}
  
                        &lt;p&gt;&lt;b&gt;Member:&lt;/b&gt; {{ membership.person }} - {{ membership.role }}&lt;/p&gt;                            
  
                  {% endfor %}
  
  
  
  
  
  
                  &lt;br&gt;
                  &lt;span class="desc2"&gt;Groups description:&lt;/span&gt;
                  &lt;p id="desc"&gt;{{g.description}}&lt;/p&gt;&lt;br&gt;
  
  
  
                  {% for membership in g.membership_set.all %}
  
                        {% if membership.leader == False %}
                          &lt;button style="float: right" type="submit" name = "leave"  value = "{{g.name}}" class="save btn btn-default"&gt;Leave&lt;/button&gt;
                        {% elif membership.leader == True %}
                          &lt;button style="float: right" type="submit" name = "delete"  value = "{{g.name}}" class="save btn btn-default"&gt;Delete&lt;/button&gt;
                        {% endif %}
  
                   {% endfor %}
                &lt;/form&gt;
                &lt;br&gt;&lt;br&gt;
                &lt;p&gt;&lt;/p&gt;
  
  
  
                  &lt;/div&gt;
                  &lt;/div&gt;
  
              {% endfor %}
  </code></pre>
  
  <p>models.py:</p>
  
  <pre><code>class Person(models.Model):
      name = models.CharField(max_length=128)
  
      def __str__(self):              # __unicode__ on Python 2
          return self.name
  
  
  class Group(models.Model):
      name = models.CharField(max_length=128)
      members = models.ManyToManyField(Person, through='Membership')
      description = models.TextField(max_length=350)
  
      def __str__(self):              # __unicode__ on Python 2
          return self.name
  
  
  class Membership(models.Model):
      person = models.ForeignKey(Person)
      leader = models.BooleanField(default=False)
      group = models.ForeignKey(Group)
      role = models.CharField(max_length=50)
  </code></pre>
  
  <p>My buttons are displeyed as many as i have users in some group.
  I want to display only 1 button, and i need to precise ForLoop only for my membership in this group. How can i do this?</p>