def add_new_user(): form = NewUser() print("errors", form.errors) if form.validate_on_submit(): tmp_usr = User(form.name.data, form.email.data, form.phone.data, form.address.data, form.address2.data, form.city.data, form.zip_code.data, form.tag_id.data, form.fortnox_id.data, form.expiry_date.data, form.birth_date.data, form.gender.data) db.session.add(tmp_usr) db.session.commit() flash('Created new user: %s with id: %s' % (form.name.data, tmp_usr.index)) tagevent = get_last_tag_event() fortnox_data = Fortnox() fortnox_data.insert_customer(tmp_usr) msg = None if tagevent is None: msg = None else: msg = (tmp_usr.index, tagevent.tag_id) form = NewUser() return render_template('new_user.html', title='New User', form=form, message=msg) return render_template('new_user.html', title='New User', form=form)