Skip to content

anonymous /gist:6434167

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
My forms.py file :)
from wtforms import Form, TextField, TextAreaField, SubmitField, validators, ValidationError, PasswordField
from models import db,User
class ContactForm(Form):
name = TextField("Name", [validators.Required("Please enter your name.")])
email = TextField("Email", [validators.Required("Please enter your email address."), validators.Email("Please enter your email address.")])
subject = TextField("Subject", [validators.Required("Please enter a subject.")])
message = TextAreaField("Message", [validators.Required("Please enter a message.")])
submit = SubmitField("Send")
# User submit form for the blog
class SignupForm(Form):
firstname = TextField("First name", [validators.Required("Please enter your first name.")])
lastname = TextField("Last name", [validators.Required("Please enter your last name.")])
email = TextField("Email", [validators.Required("Please enter your email address."), validators.Email("Please enter your email address.")])
username = TextField("Username",[validators.Required("Please enter your username.")])
password = PasswordField('Password', [validators.Required("Please enter a password.")])
submit = SubmitField("Create account")
def __init__(self, *args, **kwargs):
Form.__init__(self, *args, **kwargs)
def validate(self):
if not Form.validate(self):
return False
user = User.query.filter_by(email = self.email.data.lower()).first()
if user:
self.email.errors.append("That email is already taken")
return False
else:
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.