Django登录视图

时间:2017-01-15 20:21:16

标签: django

我正在尝试从视图中登录用户,收到错误'User' object has no attribute 'backend'

from django.contrib.auth import login

def confirmation(request):
    ...
    user = User.objects.get(id=user_id)
    login(request, user)

1 个答案:

答案 0 :(得分:0)

设置request.user = user