SHARE
TWEET

Untitled

a guest Jul 21st, 2017 25 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from django.shortcuts import render
  4. from datetime import datetime
  5. from demoapp.forms import SignUpForm
  6. from demoapp.models import UserModel
  7. from django.contrib.auth.hashers import make_password
  8. # Create your views here
  9.  
  10. def signup_view(request):
  11.   #business logic.
  12.   if request.method == 'GET':
  13.       # display signup form
  14.     today = datetime.now
  15.     form = SignUpForm()
  16.     template_name ="signup.html"
  17.  
  18.   elif request.method == 'POST':
  19.       form = SignUpForm(request.POST)
  20.       if form.is_valid():
  21.           username = form.cleaned_data['username']
  22.           email = form.cleaned_data['email']
  23.           name = form.cleaned_data['name']
  24.           password = form.cleaned_data['password']
  25.           # insert data to database
  26.           new_user = UserModel(name=name, password=make_password(password), username=username, email=email )
  27.           new_user.save()
  28.           template_name = 'success.html'
  29.   return render(request, template_name, {'form':form})
  30. # def login_view(request):
  31. #   #business logic.
  32. #    if request.method == 'GET':
  33. #     # display login form
  34. #
  35. #             today = datetime.now
  36. #       return render(request, 'login.html',{'today':today})
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top