You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
849 B

from django.shortcuts import render
from django.http import HttpResponse
from .models import User
# Create your views here.
def login(request):
if request.method == 'POST':
# 从前端数据中拿去表中字段
user_name = request.POST.get('user_name')
user_password = request.POST.get('user_password')
user_password_confirm = request.POST.get('user_password_confirm')
# 根据用户名查询数据库,并获得用户
user_obj = User.objects.filter(user_name=user_name).first()
if user_obj.user_name == user_name and user_obj.user_password == user_password and user_obj.user_password_confirm == user_password_confirm:
return HttpResponse("登录成功")
else:
return HttpResponse("登录失败")
else:
return HttpResponse("登录失败")