[Windows 10] [Development environment construction] How to resolve when unresolved import'django.xxx' python (unresolved-import) occurs in VS Code
        
      
      
   
      
Occurrence event
Unresolved import related to django occurred in vscode.
For example, unresolved import'django.urls' python (unresolved-import).
I felt uncomfortable, so how to deal with it.
Development environment
--Build a development environment with docker for Windows. The Python virtual environment uses pipenv.
| item | 
version | 
| OS | 
Window10 2004 | 
| Python | 
3.8.2 | 
| docker | 
2.3.0.5 | 
| Editor | 
VSCode:1.49.2 | 
--Various software versions of the virtual environment are as follows.
| item | 
version | 
| OS | 
ubunts:20.04 | 
| python | 
3.8.2 | 
| Django | 
3.0.6 | 
| gunicorn | 
20.0.4 | 
| psycopg2 | 
2.8.5 | 
| PostgeSQL | 
2.3 | 
| nginx | 
1.17.10 | 
Building a virtual environment
- An app folder is created under Workplaces.
 
- I'm running ** pipenv install ** directly under the app folder.
 
- The django project is created from ** pipenv shell ** directly under the app folder with ** startproject **.
 
Correspondence
1. Create an .env file directly under the workspace
2. Describe the following in the .env file
 python:.\.env
PYTHONPATH = app\.venv\Lib\site-packages
3. Check the VS Code envFile settings.
3-1. Open the settings with File-> Preferences-> Settings from the VS Code menu.

3-3. Enter "python.envFile" in the search window.
3-4. If the value of python.envFile is "$ {workspaceFolder} /.env", there is no problem as it is. Probably the path is directly under the workspace by default.

3-5. Restart VS Code.
** Probably the unresolved import related to django has been resolved **
Afterword
It's natural because it's not visible from VS Code, but ...
The site that I used as a reference
https://blog.mrym.tv/2019/08/vscode-python-unresolved-import/