为了账号安全,请及时绑定邮箱和手机立即绑定

Class 'Article' has no 'objects' member

http://img1.sycdn.imooc.com//5aa48b5f0001d8d816000680.jpg

vscode报错,但可以正常运行。效果和老师没差。有大佬知道这是为什么吗?

正在回答

2 回答

That's not an error, it's just a warning from VSC. Django adds that  property dynamically to all model classes (it uses a lot of magic  under the hood), so the IDE doesn't know about it by looking at the  class declaration, so it warns you about a possible error (it's not).  objects is in fact a Manager instance that helps with querying the DB.  If you really want to get rid of that warning you could go to all your  models and add objects = models.Manager() Now, VSC will see the  objects declared and will not complain about it again.

2 回复 有任何疑惑可以回复我~
#1

努力的阿楠

well Thanks!
2018-10-09 回复 有任何疑惑可以回复我~
#2

opos

解决办法链接:https://blog.csdn.net/ZhangK9509/article/details/80293074
2018-12-27 回复 有任何疑惑可以回复我~

models.py文件打开看一下,报错的意思从字面上看是models模块中的Article类没有objects成员。可能是Article类有问题,猜想是没继承?

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
django入门与实践
  • 参与学习       65159    人
  • 解答问题       869    个

手把手带你进入Django开发的大门,充分领略Django的魅力

进入课程

Class 'Article' has no 'objects' member

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信