问题描述
今天在学习第四章表单时,创建form实例时访问实例属性时报错,即以下代码出错
form = LoginForm()
print(form.username)
RuntimeError: Working outside of request context.
This typically means that you attempted to use functionality that needed
an active HTTP request. Consult the documentation on testing for
information about how to avoid this problem.
在论坛里看到同样的问题,问题很明确,需要请求上下文: