加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

flask开发中遇到NameError: name 'Post' is not defi

发布时间:2020-12-17 17:03:37 所属栏目:Python 来源:网络整理
导读:flask开发中遇到NameError: name 'Post' is not defined --------------------------------------------------------------------------- ImportError? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Traceback (most recent call last) E:softwarepython35libsite-pack

flask开发中遇到NameError: name 'Post' is not defined


---------------------------------------------------------------------------

ImportError? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Traceback (most recent call last)

E:softwarepython35libsite-packagesflask_scriptcommands.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)


(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读