title: Django Group Permission Check in Template
body: <p>I want to check group have permission in template for loop.</p>
  
  <p>My Context Processors</p>
  
  <pre><code>from django.contrib.auth.models import User,Group,Permission
  from django.db.models import Q
  def users(request):
      users = User.objects.filter(is_active=1).exclude(id=request.user.id)
      groups = Group.objects.exclude(Q(name='customer') | Q(name='vendor') | Q(name='labour'))
      permissions = Permission.objects.all()
  
      return {
          'all_users': users,
          'all_groups' : groups,
          'permissions' : permissions
      }
  </code></pre>
  
  <p>My template  </p>
  
  <pre><code>&lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;Permission&lt;/th&gt;
          &lt;th&gt;Content Type&lt;/th&gt;
          &lt;th&gt;Access Group&lt;/th&gt;
      &lt;/tr&gt;
      {% for permission in permissions %}
      &lt;tr class="item-row"&gt;
          &lt;td&gt;
              {{permission.name}}
              &lt;input type="hidden" name="permission_{{permission.id}}" /&gt;
          &lt;/td&gt;
          &lt;td&gt;
              {{permission.content_type.app_label}}
          &lt;/td&gt;
          &lt;td&gt;
              {% for group in all_groups %}
                  &lt;span class="checkboxes fln"&gt;
                      &lt;span class="checkbox"&gt;
                          &lt;small class="single checkNo"&gt;                                          
                              &lt;input type="checkbox" name="group_{{group.id}}_permission_{{permission.id}}"/&gt;
                          &lt;/small&gt;
                          &lt;b&gt;{{group.name}}&lt;/b&gt;
                      &lt;/span&gt;
                  &lt;/span&gt;
              {% endfor %}
          &lt;/td&gt;
      &lt;/tr&gt;
      {% endfor %}
  &lt;/table&gt;
  </code></pre>
  
  <p>If group have permission , I want to change this line.</p>
  
  <pre><code>&lt;input type="checkbox" name="group_{{group.id}}_permission_{{permission.id}}" {%if 'condition'  %} checked="checked" {% endif %}/&gt;
  </code></pre>
  
  <p>How can I check group have that permission.</p>