def index(request): user_form = UserForm(request.POST) if request.method == "POST" and user_form.validate(): new_user = UserMgr.new(username=user_form.username.data) print("new_user: "******"user_form": user_form}
def validate_username(form, field): form.user = UserMgr.one(username=field.data) if form.user is None: msg = field.data + " isn't a registered user." raise val.StopValidation(msg)
def validate_username(form, field): if UserMgr.one(username=field.data): msg = "Username {} is taken".format(field.data) raise wtforms.ValidationError(msg)
def home(request): all_users = UserMgr.get().all() return {"all_users": all_users}