You need custom template tag:
from django import template
register = template.Library()
@register.filter(name="has_group")
def has_group(user, group_name):
return user.groups.filter(name=group_name).exists()
In your template:
{% if request.user|has_group:"mygroup" %}
<p>User belongs to my group
{% else %}
<p>User doesn't belong to mygroup</p>
{% endif %}
Source: http://www.abidibo.net/blog/2014/05/22/check-if-user-belongs-group-django-templates/
Docs: https://docs.djangoproject.com/en/dev/howto/custom-template-tags/