本文整理汇总了Python中models.Contact.known_from方法的典型用法代码示例。如果您正苦于以下问题:Python Contact.known_from方法的具体用法?Python Contact.known_from怎么用?Python Contact.known_from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Contact
的用法示例。
在下文中一共展示了Contact.known_from方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import known_from [as 别名]
def create():
form = ContactForm()
if form.validate_on_submit():
new_contact = Contact()
new_name = Name()
new_contact.email = form.email.data
new_name.first_name = form.first_name.data
new_name.last_name = form.last_name.data
new_contact.name = new_name
new_contact.group = form.group.data
new_contact.known_from = form.known_from.data
new_contact.general_comment = form.general_note.data
new_contact.current_status = form.status.data
for language in form.languages.data:
if language:
new_contact.tags.append(language)
other_tags = form.other_tags.data.replace(', ', ',').split(',')
for tag in other_tags:
new_contact.tags.append(tag)
try:
new_contact.save()
flash_string = '<a href=\"/{}\">{} {}</a> was added to the database.'
flash_string = flash_string.format(new_contact.email, new_contact.name.first_name,
new_contact.name.last_name)
flash(Markup(flash_string))
update_p_dict()
return redirect(url_for('index'))
except NotUniqueError:
msg = "That email address is already in use. <a href=\"/" + form.email.data + "\">View Entry.</a>"
form.email.errors.append(Markup(msg))
except Exception as e:
flash("There were database-raised errors in the form. Specifically, " + e.message)
return render_template('create_contact.html', form=form)