def register(request):
    errmsg = ''
    if (request.method == 'POST'):
        username = request.POST.get('user_name')
        pwd = request.POST.get('pwd')
        email = request.POST.get('email')
        db_email = LoginUser.objects.filter(email=email).first()
        db_username = LoginUser.objects.filter(username=username).first()
        if (not db_email):
            if (not db_username):
                user = LoginUser()
                user.username = username
                user.password = getPassword(pwd)
                user.email = email
                user.save()
                return HttpResponseRedirect('/Buyer/login/', locals())
            else:
                errmsg = '用户名已存在'
        else:
            errmsg = '邮箱已注册'
    return render(request, 'buyer/register.html', {'errmsg': errmsg})
def register(request):
    errmsg = 
    if (request.method == 'POST'):
        username = request.POST.get('user_name')
        pwd = request.POST.get('pwd')
        email = request.POST.get('email')
        db_email = LoginUser.objects.filter(email=email).first()
        db_username = LoginUser.objects.filter(username=username).first()
        if (not db_email):
            if (not db_username):
                user = LoginUser()
                user.username = username
                user.password = getPassword(pwd)
                user.email = email
                user.save()
                return HttpResponseRedirect('/Buyer/login/', locals())
            else:
                errmsg = '用户名已存在'
        else:
            errmsg = '邮箱已注册'
    return render(request, 'buyer/register.html', {'errmsg': errmsg})