【发布时间】:2020-02-16 15:51:03
【问题描述】:
我想知道如何在应用程序初始化之前在 wtf 表单类中使用flask 中的url_for() 函数。
我的表单类如下所示:
class UserRegisterForm(FlaskForm):
accept_terms = BooleanField(
"I have read the <a href=\"{{ url_for('terms_of_service') }}\">terms of service</a><br> and I
agree with them.", validators=[DataRequired()])
现在,你看,我正在尝试在标签文本中使用url_for() 函数。不幸的是,这不起作用。
我无法在标签之外使用该功能,因为我收到了一个 rumtime 错误,因为我在生成网站之前使用了该功能。
谁能解决这个问题?
【问题讨论】:
标签: python python-3.x flask jinja2 flask-wtforms