Exemplo n.º 1
0
def reging(requset):
    if requset.method == "POST":
        vname = requset.POST["UserName"]
        vpassword = requset.POST["Password"]
        u = User(name=vname, password=vpassword)
        u.save()
        peolist = Peoson.objects.all()
        return render(requset, "getlist.html", {"peolist": peolist})
Exemplo n.º 2
0
def reging(requset):
    if requset.method == 'POST':
        vname = requset.POST['UserName']
        vpassword = requset.POST['Password']
        u = User(name=vname, password=vpassword)
        u.save()
        peolist = Peoson.objects.all()
        return render(requset, 'getlist.html', {'peolist': peolist})
Exemplo n.º 3
0
def get_user(user_id, name):
    from default.models import User

    # if user already exists retrieve it, otherwise create a new one
    usr = None
    try:
        usr = User.objects.get(user_id=user_id)
    except User.DoesNotExist:
        logger.debug("A user with ID '%i' doesn't exist yet. Adding the user to the database."%user_id)
        usr = User(user_id=user_id, name=name)
        usr.save()
    return usr
Exemplo n.º 4
0
def register(request):
    if request.method == "POST":
        name = request.POST.get('name')
        pwd1 = request.POST.get('pwd1')
        pwd2 = request.POST.get('pwd2')
        message = "注册信息不完整!"
        if name and pwd1 and pwd2:
            if pwd1 == pwd2:  # 判断两次密码是否一致
                same_user = User.objects.filter(name=name)
                if same_user:
                    message = "用户名已存在!"
                else:
                    new_user = User()
                    new_user.name = name
                    new_user.password = pwd1
                    new_user.save()
                    return redirect('/login/')
            else:
                message = "两次密码不一致!"
        return render(request, 'register.html', {'message': message})
    return render(request, 'register.html')