How to configure Visual Studio Code to debug Django app in a virtualenv?
1) Press CTRL + ,
2) Select Workspace Settings
3) Add the following line in the settings file opened.
"python.pythonPath": "path_to_your_env"
You're done!
For me, the following 2 changes worked
- Add an absolute path for pythonPath
- Use the
"--noreload"
option while starting the project
Here's the relevant part of my config
{
"name": "Django",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "/Users/xyz/Documents/dev/my_project/my_project_env/bin/python",
"program": "${workspaceRoot}/manage.py",
"args": [
"runserver",
"0.0.0.0:8080",
"--noreload"
],
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput",
"DjangoDebugging"
]
},