私は見解を持っています:
@decorator
def func(request):
hello = "hello"
return render_to_responce("test.html", locals() )
およびテンプレートtest.html:
{{ hello }}
{{ username }}
func(request)
関数に変数USERNAMEを追加し、テンプレートに2つのパラメーターを返す、のデコレーターを作成したいと思います。私はそれを次のようにしようとしました:
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