本文整理汇总了Python中models.Contact.surname方法的典型用法代码示例。如果您正苦于以下问题:Python Contact.surname方法的具体用法?Python Contact.surname怎么用?Python Contact.surname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Contact
的用法示例。
在下文中一共展示了Contact.surname方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addContact
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import surname [as 别名]
def addContact():
form = AddContactForm()
customer_choices = [(a.id, a.name) for a in Customer.query.filter_by(customer_type=CUSTOMER_TYPES['TYPE_CUSTOMER']).all()]
customer_choices = [(0, '')] + customer_choices
form.customer.choices = customer_choices
if form.validate_on_submit():
contact = Contact()
contact.first_name = form.first_name.data
contact.surname = form.surname.data
contact.phone = form.phone.data
contact.email = form.email.data
if form.customer.data and form.customer.data != '' and form.customer.data != 0:
contact.customer_id = form.customer.data
else:
contact.customer_id = None
db.session.add(contact)
db.session.commit()
flash(gettext("New contact successfully added."))
return redirect(url_for("contacts"))
return render_template('settings/addContact.html',
title=gettext("Add New Contact"),
form=form)