1、数据库数据截图
2、登录界面
3、登录失败停留在登录界面
4、登录成功进入主界面
核心代码:
Views.py
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse,JsonResponse,HttpResponseRedirect
from .models import *
def index(request):
return render(request,'news/index.html')
def mothod_show(request):
return HttpResponse(request.method)
def json1(request):
return render(request,'news/json1.html')
def json2(request):
return JsonResponse({'h1':'hello','h2':'world'})
#登陆界面
def login(request):
return render(request,'news/login.html')
#登陆成功跳转的首页
def success(request):
return render(request, 'news/success.html')
#登陆验证
def login_check(request):
# dic = {'python': '123456'}
reg = request.POST.get('user')
password = request.POST.get('password')
dic = UserInfo.objects.get(user=reg)
if dic.psw == password:
return HttpResponseRedirect('/success') #跳转界面到success界面
else:
return HttpResponseRedirect('/login') #账号或是密码错误依旧停留在输入界面
Login.html
登陆页面
资源综合
https://download.csdn.net/download/hard_days/10715262