33👍
✅
request
isn’t a keyword argument to the view, it’s the first positional argument. You can access it as args[0]
.
def foo_decorator(function):
@wraps(function)
def decorator(*args, **kwargs):
print args[0]
return function(*args, **kwargs)
return decorator
I would recommend that you change the function signature to include request
explicitly:
def foo_decorator(function):
@wraps(function)
def decorator(request, *args, **kwargs):
print request
return function(request, *args, **kwargs)
return decorator
Source:stackexchange.com