用Django做了个登入界面,跳转成功了,但是无论账号密码是否正确都能跳转到主界面,判据没执行,新手小白,请大神帮忙给看看,拜托

  • Post author:
  • Post category:其他


login.html内容如下:

{% load static %}

<br /> Login<br />
{% csrf_token %}

平台

urlpatterns = [

url(‘admin/’, admin.site.urls),

url(‘index/’, bv.index),

url(‘platform/’, bv.index_platform, name=‘index_platform’),

url(‘fenxi/’, bv.index_fenxi, name=‘index_fenxi’)

]

app下的urls.py内容如下:

from django.conf.urls import url, include

urlpatterns = [

url(r’^index’, views.index),

url(r’^platform’, views.index_platform, name=‘index_platform’),

url(r’^fenxi’, views.index_fenxi, name=‘index_fenxi’)

]

views.py内容如下:

from django.shortcuts import render

from django.shortcuts import redirect

def index(request):

return render(request, ‘login.html’)

if request.method == “POST”:

user = request.POST.get(‘user’, None)

pwd = request.POST.get(‘pwd’, None)

if user == ‘root’ and pwd == ‘12



版权声明:本文为cgy_huangyb原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。