def savedata(request): check_user = User.objects.all() if request.method == 'POST': form = reg(request.POST) if form.is_valid(): for user_name in check_user: if user_name.username == form.cleaned_data['username'] : state = "This Username is already existed. Plz take any other name" return render_to_response('registration.html',locals()) usert = User.objects.create( username = form.cleaned_data['username'], first_name = form.cleaned_data['first_name'], last_name = form.cleaned_data['last_name'], email = form.cleaned_data['email'], password = form.cleaned_data['password'], #re-password = form.cleaned_data['re-password'], ) usert.re_password = form.cleaned_data['re_password'] usert.save() #print "send mail" if usert.password != usert.re_password : state = "Your passwords do not match" return render_to_response('registration.html',locals()) usert.set_password(str(form.cleaned_data['password'])) usert.save() user = UserProfile.objects.create( user = usert, address = form.cleaned_data['address'], user_type = form.cleaned_data['user_type'], password2 = form.cleaned_data['password'], ) user.save() print user.user.email send_mail('Registered User Confirmation', 'Welcome to Pg/Room Services', '*****@*****.**', [user.user.email]) #send_sms("This is demo","09632120841" ,"09017060099") #api.send_sms(body='This is demo', from_phone='+919632120841', to=['+919017060099']) return render_to_response('savedata.html',locals()) else: return render_to_response('registration.html',locals()) else: print "not working " form = reg() return render_to_response('registration.html',locals())
def register(request): form = reg() return render_to_response('registration.html',locals())