Skip to content

Jedi cannot locate a Django class's attributes. #14648

@programming-paradox

Description

@programming-paradox

Environment data

  • VS Code version: 1.50
  • Extension version (available under the Extensions sidebar): 2020.10.332292344
  • OS and version: Windows 10 Pro
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.7
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): Venv
  • Value of the python.languageServer setting: Jedi

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behavior

The python extension for visual studio is showing a strange error while being used with Django the web framework for python. When we make models and import them in our views and try to filter out specific values from the database it shows a red line saying the XYZ model has no objects member.

image

But the code runs fine. I have also tried this in other editors like pycharm and atom and they don't show this error. But the code and the execution runs fine in all the editors but visual studio code gives a strange red line of error. Wherever we use the models.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Error 2020-11-06 14:11:36: stderr jediProxy Error (stderr) c:\Users\Dell\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\completion.py:603: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).goto instead.
  script.goto_assignments(follow_imports=True), request["id"]

Error 2020-11-06 14:11:36: stderr jediProxy Error (stderr) c:\Users\Dell\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\completion.py:598: DeprecationWarning: Providing the line is now done in the functions themselves like `Script(...).complete(line, column)`
  sys_path=sys.path,
c:\Users\Dell\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\completion.py:598: DeprecationWarning: Providing the column is now done in the functions themselves like `Script(...).complete(line, column)`
  sys_path=sys.path,

Error 2020-11-06 14:11:36: stderr jediProxy Error (stderr) c:\Users\Dell\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\completion.py:598: DeprecationWarning: Deprecated since version 0.17.0. Use the project API instead, which means Script(project=Project(dir, sys_path=sys_path)) instead.
  sys_path=sys.path,
c:\Users\Dell\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\completion.py:626: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).infer instead.
  script.goto_definitions(), request["id"]

> e:\Amazon\Venv\Scripts\python.exe c:\Users\Dell\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py autopep8 --diff e:\Amazon\Shop\views.py
cwd: e:\Amazon
> e:\Amazon\Venv\Scripts\python.exe c:\Users\Dell\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py autopep8 --diff e:\Amazon\Shop\views.py
cwd: e:\Amazon
> e:\Amazon\Venv\Scripts\python.exe c:\Users\Dell\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py pylint --disable=all --enable=F,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0107,E0108,E0110,E0111,E0112,E0113,E0114,E0115,E0116,E0117,E0118,E0202,E0203,E0211,E0213,E0236,E0237,E0238,E0239,E0240,E0241,E0301,E0302,E0303,E0401,E0402,E0601,E0602,E0603,E0604,E0611,E0632,E0633,E0701,E0702,E0703,E0704,E0710,E0711,E0712,E1003,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text e:\Amazon\Shop\views.py
cwd: e:\Amazon
> e:\Amazon\Venv\Scripts\python.exe c:\Users\Dell\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\pyvsc-run-isolated.py pylint --disable=all --enable=F,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0107,E0108,E0110,E0111,E0112,E0113,E0114,E0115,E0116,E0117,E0118,E0202,E0203,E0211,E0213,E0236,E0237,E0238,E0239,E0240,E0241,E0301,E0302,E0303,E0401,E0402,E0601,E0602,E0603,E0604,E0611,E0632,E0633,E0701,E0702,E0703,E0704,E0710,E0711,E0712,E1003,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text e:\Amazon\Shop\views.py
cwd: e:\Amazon
##########Linting Output - pylint##########
************* Module Shop.views
18,14,error,no-member:Class 'Product' has no 'objects' member
25,4,warning,unused-variable:Unused variable 'cart'
33,4,warning,unused-variable:Unused variable 'cart'
41,4,warning,unused-variable:Unused variable 'cart'

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

Your code has been rated at 6.92/10 (previous run: 6.92/10, +0.00)

Metadata

Metadata

Labels

area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from poster

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions