flask开发中遇到nameError: name 'Post' is not defined
---------------------------------------------------------------------------
importError Traceback (most recent call last)
E:\software\python35\lib\site-packages\flask_script\commands.py in run(self,no_ipython,no_bpython)
299 # 0.10.x
--> 300 from IPython.Shell import IPShellEmbed
301 ipshell = IPShellEmbed(banner=self.banner)
importError: No module named 'IPython.Shell'
During handling of the above exception,another exception occurred:
nameError Traceback (most recent call last)
<ipython-input-1-73735930ffba> in <module>()
----> 1 Post.query.all()
nameError: name 'Post' is not defined
报这个错误原因在于manager.py中没有引入Post,解决方法:
from app.models import User,Role,Post
def make_shell_context():
return dict(app=app,db=db,User=User,Role=Role,Post=Post)
以上是内存溢出为你收集整理的flask开发中遇到NameError: name 'Post' is not defined全部内容,希望文章能够帮你解决flask开发中遇到NameError: name 'Post' is not defined所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)