Exemple #1
0
def doregister(request):
    '''执行注册'''
    try:
        ob = Users()
        ob.username = request.POST['username']
        ob.name = request.POST['name']
        import hashlib
        m = hashlib.md5()
        m.update(bytes(request.POST['password'], encoding="utf8"))
        ob.password = m.hexdigest()
        ob.state = 1
        ob.create_at = datetime.now()
        ob.update_at = datetime.now()
        ob.save()
    except Exception as err:
        print(err)

    return render(request, "myadmin/login.html")
Exemple #2
0
def insert(request):
    '''执行添加信息'''
    try:
        ob = Users()
        ob.username = request.POST['username']
        ob.name = request.POST['name']
        import hashlib
        m = hashlib.md5()
        m.update(bytes(request.POST['password'], encoding="utf8"))
        ob.password = m.hexdigest()
        ob.state = 1
        ob.create_at = datetime.now()
        ob.update_at = datetime.now()
        ob.save()
        context = {"info": "添加成功"}

    except Exception as err:

        print(err)
        context = {"info": "添加失败"}
    return render(request, 'myadmin/info.html', context)