Argument of type 'function' is not iterable

def allowed_users(allowed_roles=[]):
    def decorator(view_func):
        def wrapper_func(request, *args, **kwargs):

            group = None
            if request.user.groups.exists():
                group = request.user.groups.all()[0].name
            
            if group in allowed_users:
                return view_func(request, *args, **kwargs)
            else:
                return HttpResponse('You are not authorized to view this Page')
        return wrapper_func
    return decorator
Back to Top