Django中的用户注册表

时间:2015-08-04 14:27:24

标签: python django-forms

我正在尝试为我的网站编写注册表,我的代码如下。问题是,当我按下注册页面中的提交按钮时,实际上没有发生任何事情...我已经感谢你的帮助。

register.html

<form id="reg_form" action="/register/" method="post" >
    <div class="container">
        <div class="row">

            <div class="col-md-6">
                <div class="corner" style="margin-top: 5pt;">
                    <label>قوانین عضویت:</label>

                    <div class="form-group">
                        <label for="accept">با قوانین سایت موافقم</label>
                        <input type="checkbox"  id="accept"/>
                    </div>
                </div>

               <button type="submit" class="btn btn-success" data-dismiss="modal" style="width: 100%;font-size: xx-large; margin-top: 10pt;">ثبت</button>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label for="fname">نام:</label>
                    <input type="text" class="form-control" id="fname"/>
                </div>
                <div class="form-group">
                    <label for="lname">نام خانوادگی:</label>
                    <input type="text" class="form-control" id="lname">
                </div>
                <div class="form-group">
                    <label for="email">ایمیل:</label>
                    <input type="email" class="form-control" id="email">
                </div>
                <div class="form-group">
                    <label for="phone">شماره تماس:</label>
                    <input type="text" class="form-control" id="phone">
                </div>
                <div class="form-group">
                    <label for="address">آدرس:</label>
                    <input type="text" class="form-control" id="address">
                </div>
                <div class="form-group">
                    <label for="pwd">رمز عبور:</label>
                    <input type="password" class="form-control" id="pwd">
                </div>
                <div class="form-group">
                    <label for="pwd2">تکرار رمز عبور:</label>
                    <input type="password" class="form-control" id="pwd2">
                </div>

            </div>
        </div>

    </div>
    </form>

views.py ________________________________________________________________

def register(request):
    if request.method == 'POST':
        fname=request.POST['fname']
        lname=request.POST['lname']
        email=request.POST['email']
        phone=request.POST['phone']
        address=request.POST['address']
        pwd=request.POST['pwd']

        user=User.objects.create_user(username=email, password=pwd )
        user.save()
        return HttpResponseRedirect("/home/")
    return render(request, 'Register.html')

0 个答案:

没有答案