0

我正在创建一个个人资料页面,并且需要获取id请求用户的信息,因此我可以循环它的信息。

我正在使用这个视图:

def profile(request):  
    if request.user.is_authenticated:
        user = request.user
        us = User.objects.get(username=user)
        context = { 'us': us }
    return render(request, context, "frontend/profile.html")

和路径:

path('perfil/', views.profile, name="profile")

但是当我尝试访问该页面时,出现以下错误:

join() argument must be str, bytes, or os.PathLike object, not 'dict'
4

1 回答 1

1

用户已经在您的模板中可用:{{user.username}}或任何您想要的。

对于您的代码,渲染没有好的参数:

return render(request,"frontend/profile.html", context) 
于 2020-03-13T14:28:56.130 回答