Class 'Article' has no 'objects' member
vscode报错,但可以正常运行。效果和老师没差。有大佬知道这是为什么吗?
vscode报错,但可以正常运行。效果和老师没差。有大佬知道这是为什么吗?
2018-03-11
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.
举报