I want to open a folder at the level above a Django project directory (project_parent below) in VS Code and have the linter correctly resolve the Django project imports:
| project_parent
| -- | django_project_dir
| -- | -- | manage.py
If I do this, the linter is confused and I get a bunch of warnings on imports from the Django modules in the project:
unresolved import 'module.models' Python(unresolved-import)
If I open VS Code at the the Django project folder level, the linter resolves all of the imports. This isn't ideal though because I have to close and re-open VS Code at the level above to see other related code (Ansible, bash scripts, etc.)
My question is how to update VS Code settings to add the Django project directory to the linter path?
Env:
VS Code: 1.40.1
Python: 3.7.2
Django: 2.2.1
Related question: Pylint "unresolved import" error in visual studio code
You want to update your "python.autoComplete.extraPaths" setting to include the sub-directory where you have your code that isn't being found.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With