呼唤远方

模板中可以直接使用request对象的,比如request.user。如果不能的话需要settings中进行配置TEMPLATES的OPTIONS.context_processors增加django.template.context_processors.request:TEMPLATES=[{'BACKEND':'django.template.backends.django.DjangoTemplates','DIRS':[os.path.join(DIRNAME,"templates")],'APP_DIRS':True,'OPTIONS':{'debug':DEBUG,'context_processors':['django.template.context_processors.request',],},},]
0 0