From a722f4267832ce86e8a86942b50d636c258cfd5e Mon Sep 17 00:00:00 2001 From: Kyle Roux Date: Tue, 16 May 2017 11:23:43 -0700 Subject: [PATCH] simplified more form stuff --- app.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/app.py b/app.py index 562a45a..58901c6 100644 --- a/app.py +++ b/app.py @@ -27,15 +27,10 @@ def new_contact(): Create new contact ''' form = ContactForm() - if form.validate_on_submit(): - # Get form - name = form.name.data - surname = form.surname.data - email = form.email.data - phone = form.phone.data - # Save in database + if form.validate_on_submit(): try: - my_contact = Contact(name, surname, email, phone) + my_contact = Contact() + form.populate_obj(my_contact) db.session.add(my_contact) db.session.commit() # User info