Django context must be a dict rather than UserProfile.

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>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>企业数字化管理平台</title>
</head>
<body>
<h1>你好{{ data.username }}</h1>
</body>
</html>
posted @ 2023-02-15 10:28  侬侬发  阅读(12)  评论(0编辑  收藏  举报