本文整理汇总了Python中models.Form.message方法的典型用法代码示例。如果您正苦于以下问题:Python Form.message方法的具体用法?Python Form.message怎么用?Python Form.message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Form
的用法示例。
在下文中一共展示了Form.message方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from models import Form [as 别名]
# 或者: from models.Form import message [as 别名]
def create():
form = ContactForm()
if form.validate() is False:
for error_type in form.errors:
if form.errors[error_type][0] in dictionary():
form.errors[error_type][0] = dictionary()[form.errors[error_type][0]]
return render_template('contact/index.html', form=form, action=url_for('contact.create'))
else:
contact = Form()
contact.name = form.name.data
contact.email = form.email.data
contact.subject = form.subject.data
contact.message = form.message.data
contact.postage_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
message_tpl = render_template('contact/message_template.html', contact=contact)
db.session.add(contact)
db.session.commit()
send_mail("Contato - DataViva", [admin_email], message_tpl)
message = gettext("Your message has been sent successfully. We will soon get back to you.")
flash(message, 'success')
return redirect(url_for('contact.create'))
示例2: create
# 需要导入模块: from models import Form [as 别名]
# 或者: from models.Form import message [as 别名]
def create():
form = ContactForm()
if form.validate() is False:
return Response(status=400, mimetype='application/json')
else:
contact = Form()
contact.name = form.name.data
contact.email = form.email.data
contact.subject = form.subject.data
contact.message = form.message.data
contact.postage_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
message_tpl = render_template(
'contact/message_template.html', contact=contact)
db.session.add(contact)
db.session.commit()
send_mail("Mensagem recebida via página de Contato",
["[email protected]"], message_tpl)
message = gettext(
"Your message has been sent successfully. We will soon get back to you.")
return Response(message, status=200, mimetype='application/json')