在django注销时如何获取用户

How to get the user while Logout In django

我试图让用户从 django 注销并将其作为参数传递给外部 python 脚本。 这是我的注销视图:

def logoutUser(request):
    user = request.user
    exec = run([sys.executable,'scriptlogout.py', user], shell=False, stdout=PIPE)
    logout(request)
    return redirect('beesy:Login')

但这不起作用,我无法检索用户点击注销

谢谢你帮助我

谢谢大家,我用过 str() 并且效果很好:

def logoutUser(request):
    user = str(request.user)
    exec = run([sys.executable,'scriptlogout.py', user], shell=False, stdout=PIPE)
    logout(request)
    return redirect('beesy:Login')