I'm trying to understand how to configure Pylance to make it work correctly in my Django project.
Below is one of many examples where Pylance is not able to find what I'm looking for. Here, I obviously need models
from django.db
. But there are only theses 6 suggestions below...
Here is what I know or tried:
- My interpreter is correctly selected (Python 3.10.4)
- Pylance seems to work perfectly with Python (not Django) related stuff.
- I'm using Poetry as a package manager, and no virtual env because I work in a self-contained dev container. There is only one python installed on it.
- In my VS Code config (using devcontainer.json) :
"python.analysis.extraPaths": ["${workspaceFolder}/dj_proj/dj_apps"]
-> which works to prevent missing imports. I have no false warnings about missing imports, just the inability to see the right suggestions in intellisense. - I cleaned
__pycache__
and.pyc
files -> no effect - I ensured there is a
__init__.py
pretty much everywhere - my
sys.path
(PYTHONPATH) looks like this (wheredj_proj
is my django project anddj_apps
my apps folder):
['/workspace/dj_proj/dj_apps',
'/workspace/dj_proj',
'/usr/local/lib/python310.zip',
'/usr/local/lib/python3.10',
'/usr/local/lib/python3.10/lib-dynload',
'',
'/usr/local/lib/python3.10/site-packages']
I'm suspecting this PYTHONPATH variable to be messy or not sorted the right way, but I'm not sure.
Any idea on what could be wrong? Thanks!
from Pylance Intellisense not working as expected with Django
No comments:
Post a Comment