Django python Registration

Source: Internet
Author: User
Tags button type
def regist (Request): C ={} c.update (CSRF (Request)) if request.method== "POST": Username =request. post[' username '] email = Request. post[' email '] Password = Request. post[' password '] password1 = Request. post[' Password1 '] if username = = "" or email = = "" or Password = = "" or Password1 = "": Return Httprespon SE ("Did you forget to fill out a certain item?") ") If password!= password1:return httpresponse (" Two input passwords inconsistent! ") ") users = User.objects.filter (username__iexact=username) emails = User.objects.filter (email__iexact=email If Users:return httpresponse ("Repeat user name), please re-enter." ") If Emails:return HttpResponse (" Mailbox Repeat, please re-enter ") Else:user = User.objects.create_u Ser (Username,email,password) if user isn't None:user.save () return HTTPRESPO NSE ("Registered successfully, please login") Else:return HttpResponse ("registration failed") return Render_to_response("regist.html", c) 

Templates/regist.html

<form action= "./admin/" method= "post" class= "Navbar-form pull-right" >
{% csrf_token%}
              <input "SPAN2" name = "username" type= "text" placeholder= "username" >
              <input class= "span2" name= "password"  type = "Password" 

placeholder= "password" >
              <button type= "Submit" class= "BTN" > Landing </button>
            </form>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.