from django import template
from django.contrib.auth.models import User, Group

register = template.Library()

#
# @register.filter(name='has_group')
# def has_group(user, group_name):
#     group = Group.objects.get(name=drivers)
#     if group in user.groups.all():
#         return True
#     else:
#         return False


@register.filter(name='has_group')
def has_group(user, drivers):
    return user.groups.filter(name=drivers).exists()
