【发布时间】:2014-06-20 11:58:17
【问题描述】:
我正在使用 django 身份验证来登录用户:
def signin(request):
if request.method == "POST":
username = request.POST.get("username").lower()
password = request.POST.get("password").lower()
user = authenticate(username = username, password=password)
但是,我似乎无法在任何其他视图中访问当前用户。在每个模板中,我都可以访问用户,但我似乎无法访问视图本身。例如,在另一条路线中,我希望能够执行以下操作:
def profile(request):
skills = hasSkill.objects.filter(user__username=user.username)
return render(request, "/profile.html", {"skills" : skills})
但我不断收到用户是 Nonetype 对象的错误。有什么想法吗?
【问题讨论】:
标签: python django django-views django-authentication