Exemplo n.º 1
0
def login(request):
    """显示登录界面"""
    if request.method == 'POST':
        u = User()
        u.user_name = request.POST.get('username')
        u.user_password = request.POST.get('password')
        print(u.user_name, u.user_password)
        return redirect("/today/")
    else:
        return render(request, 'index/login.html')
Exemplo n.º 2
0
def register(request):
    if request.method == 'POST':
        username = request.POST.get('username')
        password = request.POST.get('password')
        u = User()
        u.user_name = username
        u.user_password = password
        u.save()
        u_id = u.id
        return JsonResponse({'res': '1', 'uid': u_id})
    return render(request, 'index/register.html')