我密码修改成功后,自己登出时出错了
来源:10-5 修改密码和修改头像2
幕疯子
2017-07-05
写回答
3回答
-
登出后 跳转到了login 的url 你的跳转到login的url后台view是什么 你可以在url后面加上/ 然后再试试
122017-07-06 -
幕疯子
提问者
2017-07-06
urlpatterns = [ url(r'^xadmin/', xadmin.site.urls), url(r'^login/$', LoginView.as_view(), name='login'), url(r'^register/$', RegisterView.as_view(), name='register'), url(r'^captcha/', include('captcha.urls')), url(r'^active/(?P<active_code>.*)/$', ActiveUser.as_view(), name='active'), url(r'^reset/(?P<active_code>.*)/$', ResetView.as_view(), name='reset'), url(r'^$', TemplateView.as_view(template_name='index.html'), name='index'), url(r'^forgetpwd/$', ForgetPwdView.as_view(), name='forgetpwd'), url(r'^modify_pwd/$', ModifyPwdView.as_view(), name='modify'), # 课程机构url配置 url(r'^org/', include('organiztions.urls', namespace='org')), # 课程相关url配置 url(r'^course/', include('courses.urls', namespace='courses')), # 配置上传文件的访问处理函数 url(r'^media/(?P<path>.*)/$', serve, {"document_root": MEDIA_ROOT}), # 用户相关 url(r'^user/', include('users.urls', namespace='users')), ]
00 -
幕疯子
提问者
2017-07-06
class LoginView(View): def get(self, request): return render(request, 'login.html', {}) def post(self, request): login_form = LoginForm(request.POST) if login_form.is_valid(): user_name = request.POST.get('username', "") pass_word = request.POST.get('password', "") user = authenticate(username=user_name, password=pass_word) # 用户验证, 如果验证失败则值为None if user is not None: if user.is_active: login(request, user) return render(request, "index.html", {'user': user_name}) else: return render(request, 'login.html', {'msg': '用户未激活!'}) else: return render(request, 'login.html', {'msg': '用户名或密码错误!'}) else: return render(request, 'login.html', {'login_form': login_form})
00
相似问题