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