我正在尝试根据组织的 ID 填充角色,但似乎 WT 表单不支持会话
视图.py
@users.route('/', methods=['GET', 'POST'])
@users.route('/manage', methods=['GET', 'POST'])
@login_required
def manage_users():
form = User_Form()
return render_template('account/manage_users.html', form=form)
user_form.py
from flask import session
from wtforms import Form, SelectField, TextField, PasswordField, validators
class User_Form(Form, session):
username = TextField('Username', [validators.Length(min=4, max=25)])
password = PasswordField('New Password', [
validators.Required(),
validators.EqualTo('confirm', message='Passwords must match')
])
confirm = PasswordField(u'Repeat Password')
email = TextField(u'Email', [validators.Length(min=6, max=35)])
active = SelectField(u'Active', choices=[('1', 'True'), ('0', 'False')])
organization_id = session['user_id']
#role = "list roles according to organization_id"
_lookup_req_object 中的文件“C:\Users\dell\Envs\surveyApp\lib\site-packages\flask\globals.py”,第 20 行引发 RuntimeError('working outside of request context') RuntimeError: working outside of request context