from django.shortcuts import render, HttpResponse
from app import models
Create your views here.
from django.views import View
class Login(View):
def get(self, request):
return render(request, ‘login.html’)
def post(self, request):
result = {'error': ''}
name = request.POST.get('username')
pwd = request.POST.get('password')
if name == 'zs':
if pwd == '123':
return HttpResponse('ok...')
else:
result['error'] = '密码不正确'
else:
result['error'] = '用户名不正确'
return render(request, 'login.html', locals())
def index(request):
return render(request, ‘index.html’)