simplified more form stuff
This commit is contained in:
parent
19abb0749d
commit
a722f42678
11
app.py
11
app.py
@ -27,15 +27,10 @@ def new_contact():
|
|||||||
Create new contact
|
Create new contact
|
||||||
'''
|
'''
|
||||||
form = ContactForm()
|
form = ContactForm()
|
||||||
if form.validate_on_submit():
|
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
|
|
||||||
try:
|
try:
|
||||||
my_contact = Contact(name, surname, email, phone)
|
my_contact = Contact()
|
||||||
|
form.populate_obj(my_contact)
|
||||||
db.session.add(my_contact)
|
db.session.add(my_contact)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
# User info
|
# User info
|
||||||
|
Loading…
Reference in New Issue
Block a user