Specs:
- Visual Studio Code 2019
- lattest pip version
- Django 2.2+ version
- Python latest 3.7 version
Specs:
Just solved it, thanks to this SO question (VS Code error when importing Django module).
Chances are you installed into a Python environment different from the one you have chosen in VS Code. There are two ways to solve this.
The best solution is to create a virtual environment and then install into it using python -m pip. You should never use just the straight pip command as that will install into the last Python you installed which happens to be set earliest in your PATH.
The other option is to figure out which Python environment you installed Django into and make sure that's the one you have selected in VS Code.
Details on environment selection and such can be found at https://code.visualstudio.com/docs/python/environments.
In your open your Visual code and then open Command Palette and shortcut is Ctrl+SHIFT+P And then type there python select interpreter and it will give you your environment name and click it the moment you click it it will create a vscode folder in your project it will resolve
It is probably just a linter problem. Are you using the MS Python Extension? If not, please get it from here: https://marketplace.visualstudio.com/items?itemName=ms-python.python
Also, install the django support extension "Djaneiro" in case you don't have it yet, from here: https://marketplace.visualstudio.com/items?itemName=thebarkman.vscode-djaneiro.
Please refer to the below link to see further details in configuring a Django development environment in vs code. https://djangocentral.com/visual-studio-code-setup-for-django-developers/