django 1.8 以后 setting
TEMPLATES = [
{
‘BACKEND’: ‘django.template.backends.django.DjangoTemplates’,
‘DIRS’: [],
‘APP_DIRS’: True,
‘OPTIONS’: {
‘context_processors’: [
…
‘django.template.context_processors.request’,
…
],
},
},
]
然后在模板中 调用{{ request.user }}