I have view:
@decorator
def func(request):
hello = "hello"
return render_to_responce("test.html", locals() )
and template test.html:
{{ hello }}
{{ username }}
I want to write decorator for func(request)
, which adds a variable, USERNAME, to the function and returns two parameters in the template. I tried to make it as follows:
def decorator(func):
def wrapper( request, *args, **kwargs):
username = request.user.username
q = func(request, *args, **kwargs)
#what I need add here I do not know ...
return q
return wrapper