Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在django中验证注册表单_Django - Fatal编程技术网

在django中验证注册表单

在django中验证注册表单,django,Django,我有这个html表单,我想用于注册客户 <form id='registration-form'> {% csrf_token %} <div class="form-group"> <input type="text" class="form-control input-upper" id="fullname" placeholder="Jo

我有这个html表单,我想用于注册客户

<form id='registration-form'>
                    {% csrf_token %}
                    <div class="form-group">
                      <input type="text" class="form-control input-upper" id="fullname" placeholder="John Doe" name="fullname" ><br>
                      <input type="text" class="form-control input-upper" id="username" placeholder="Username" name="username"><br>
                      <input type="email" class="form-control input-upper" id="email" placeholder="Email" name="email"><br>
                      <input type="text" class="form-control input-upper" id="organization" placeholder="Organization" name="organization"><br>
                      <input type="password" class="form-control input-upper" id="password" placeholder="Password" name="password"><br>
                      <input type="password" class="form-control input-upper" id="password" placeholder="Confirm Password" name="password"><br>
                      <small>By registering you agree to our <a href="{% url 'tos' %}">terms and conditions</a></small>
                      <button type="button" class="btn btn-primary btn-block btn-signup-form">SIGN UP</button>
                      <button type="button" class="btn btn-primary btn-block btn-sign-linkedin" href="{% url 'social:begin' 'linkedin-oauth2' %}?next={{ next }}">Sign up with LinkedIn</button>
                      <p class="text-already">Already have an account? <a href="">LOGIN</a></p>
                    </div>
                </form>

{%csrf_令牌%}






通过注册,您同意我们的 注册 注册LinkedIn

已经有账户了吗


我如何对填写的数据(即电子邮件和密码)进行验证,我希望客户能够在注册后登录

我不确定验证数据是什么意思,但如果我正确获取了您的数据,您应该使用Django内置功能创建用户。Django附带了Auth模块,它可以减少您的工作量,并且可以处理大多数痛苦的部分。看看这篇文章

如果您想要简单的验证,可以使用Django表单的干净方法。编写一个表单类,其字段与前面提到的相同。 前


您需要使用Django表单,如。在网上其他地方有很多例子,只要搜索“django创建用户表单”。但是我可以使用这个html模板,并以某种方式将其解析为django进行验证和身份验证。你可以!在模板中使用表单时,您将没有一些功能(如单个字段的错误消息),但从技术上讲,只要您提交csrf_令牌,就可以使用您自己的HTML表单。好的,我现在必须弄清楚。谢谢您为我指出了正确的方向
Class  SignupForm2(forms.ModelForm ):
  class Meta:
       model = User 

  def clean(self):
      self.cleaned_data = super(SignupForm2, self).clean()

        if 'captcha' in self._errors and self._errors['captcha'] != ["This field is required."]:
        self._errors['captcha'] = ["Please enter a correct value"]
    return self.cleaned_data