def vary_on_user(view): @wraps(view, assigned=available_attrs(view)) def inner_func(request, *args, **kwargs): request.META['HTTP_DJANGO_USERID'] = request.user.id response = view(request, *args, **kwargs) patch_vary_headers(response, ('DJANGO_USERID',)) return response return inner_func