group check template tag

This commit is contained in:
gw3000 2023-08-09 21:58:30 +02:00
parent 0fcec94275
commit cc02b4126b
3 changed files with 34 additions and 20 deletions

View file

View file

@ -0,0 +1,9 @@
from django import template
from django.contrib.auth.models import Group
register = template.Library()
@register.filter(name='group_check')
def has_group(user, group_name):
group = Group.objects.get(name=group_name)
return True if group in user.groups.all() else False