def register(): """Handle registration; show form or process results.""" form = RegisterForm() openid_form = OpenIDForm() if openid_form.validate_on_submit(): return oid.try_login( openid_form.openid.data, ask_for=['nickname', 'email'], ask_for_optional=['fullname'], ) if form.validate_on_submit(): new_user = User(username=form.username.data) new_user.set_password(form.username.data) db.session.add(new_user) db.session.commit() flash( "Your user has been created, please login.", category="success" ) return redirect(url_for('.login')) openid_errors = oid.fetch_error() if openid_errors: flash(openid_errors, category='danger') return render_template('register.html', form=form, openid_form=openid_form)
def register(request): try : if request.session['username'] : return HttpResponseRedirect('/success/') except: pass #A Http Post if request.method =='POST' : form = RegisterForm(request.POST) #Checking the validity of the form if form.is_valid(): #then Save the form form.save() #Now send the user to home page return HttpResponseRedirect('/login/') else: #the form contains error return the error print (form.errors) else: #If the request was not a POST method then show the form to enter the details form = RegisterForm() #Render the form with error if supplied return render(request,'blogapp/register.html',{'form':form})
def register(request): # A Http Post if request.method == "POST": form = RegisterForm(request.POST) # Checking the vlaidity of the form if form.is_valid(): # then Save the form form.save() # Now send the user to home page return HttpResponseRedirect("/login/") else: # the form contains error return the error print(form.errors) else: # If the request was not a POST method then show the form to enter the details form = RegisterForm() # Render the form with error if supplied return render(request, "blogapp/register.html", {"form": form})