context must be a dict rather than UserProfile.
# 主页
@login_required
def index(request):
data={}
data = request.user
print(type(data))
print(data)
return render(request, 'index.html',{"data":data})
# index.html
<!DOCTYPE html>标签:index,rather,Django,dict,data,than,UserProfile From: https://www.cnblogs.com/beichengshiqiao/p/17121884.html
<html lang="en">
<head>
<meta charset="UTF-8">
<title>企业数字化管理平台</title>
</head>
<body>
<h1>你好{{ data.username }}</h1>
</body>
</html>