場景
- 在使用django時,源碼如下
from django.http import HttpResponse
from .models import Question
def index(request):
boards = Question.objects.all()
...
- 工具檢測報錯如下
: Class 'Question has no objectsmember`
方案
- 安裝
pylint_django
並對ide(以vscode爲例)添加相應配置
pip install pylint-django
- 添加配置
User Settings (Ctrl + , or File > Preferences > Settings
"python.linting.pylintArgs": [
"--load-plugins=pylint_django",
]