def validate(self):
    initial_validation = super(RegisterForm, self).validate()
    if (not initial_validation):
        return False
    user = db_session.query(User).filter_by(username=self.username.data).first()
    if user:
        self.username.errors.append('Username already registered')
        return False
    user = User.query.filter_by(email=self.email.data).first()
    if user:
        self.email.errors.append('Email already registered')
        return False
    return True
def validate(self):
    initial_validation = super(RegisterForm, self).validate()
    if (not initial_validation):
        return False
    user = db_session.query(User).filter_by(username=self.username.data).first()
    if user:
        self.username.errors.append('Username already registered')
        return False
    user = User.query.filter_by(email=self.email.data).first()
    if user:
        self.email.errors.append('Email already registered')
        return False
    return True