obj = Profile.objects.get(user=request.user)
obj_perms = obj.permission_tags.all()
flag = False
for p in obj_perms:
    if perm.lower() == p.codename.lower():
        flag = True
return flag
Django - How to use custom template tag with 'if' and 'else' checks?