0
@user.route('/', methods=['POST'])
def create():
    form = CreateUserForm()

    if form.validate_on_submit():
        user_datastore.create_user(form)

Using both libraries together, is there some way that I can do as in the code above. I want to pass the form (with its fields) directly to create_user, so that I don't have to split each field just to add them there. Is this possible?

rablentain
  • 6,641
  • 13
  • 50
  • 91

1 Answers1

0

Create a user from the form's data and then put it in the datastore

form = CreateUserForm(request.form)
if form.validate_on_submit():
    user = User()
    form.populate_obj(user) # Copies matching attributes from form onto user
    user_datastore.put(user)
pjcunningham
  • 7,676
  • 1
  • 36
  • 49