6-2章节登录后提示报错TypeError at /login/
来源:6-2 用户登录-1
匿名扫地僧
2018-08-10
老师好,6-2章节登录后提示报错如下,检查了一遍没找到什么问题:
from users.views import login urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url('^$',TemplateView.as_view(template_name="index.html"),name="index"), url('^login/$',login,name="login") ]
from django.shortcuts import render from django.contrib.auth import authenticate # Create your views here. def login(request): if request.method == "POST": user_name = request.POST.get("username","") pass_word = request.POST.get("password","") user = authenticate(user_name,pass_word) if user is not None: login(request,user) return render(request,"index.html") else: return render(request, "login.html", {}) elif request.method == "GET": return render(request,"login.html",{})
写回答
4回答
-
kr1240
2019-06-27
user = authenticate(username=user_name, password=pass_word)
已经改过了。
012019-07-01 -
kr1240
2019-06-27
这个怎么解决的?我也碰到了同样的问题。处理了1个多小时了!
00 -
bobby
2018-08-13
https://git.imooc.com/Project/coding-78 你可以到这里查看我的源码 拷贝我的逻辑运行试试
00 -
慕丝4554142
2018-08-13
你试着把authenticate里面的参数变成这样authenticate(username=user_name,password=pass_word)看看
00
相似问题