I would like to have possibility to do a debugging of Django application in Visual Studio Code. I have a virtualenv, made a change in launch.json file that look like this:
JavaScript
x
18
18
1
{
2
"name": "Django",
3
"type": "python",
4
"request": "launch",
5
"stopOnEntry": true,
6
"pythonPath": "${workspaceRoot}/.venv/bin/python2.7",
7
"program": "${workspaceRoot}/mysite/manage.py",
8
"args": [
9
"runserver"
10
],
11
"debugOptions": [
12
"WaitOnAbnormalExit",
13
"WaitOnNormalExit",
14
"DjangoDebugging",
15
"RedirectOutput"
16
]
17
},
18
put several break points in the code and run it. Unfortunately, the execution is not stopped on the line with break points. I tried the same without virtualenv and everything worked perfectly.
Please, point out what I am doing wrong here.
Advertisement
Answer
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
JavaScript
1
20
20
1
{
2
"name": "Django",
3
"type": "python",
4
"request": "launch",
5
"stopOnEntry": true,
6
"pythonPath": "/Users/xyz/Documents/dev/my_project/my_project_env/bin/python",
7
"program": "${workspaceRoot}/manage.py",
8
"args": [
9
"runserver",
10
"0.0.0.0:8080",
11
"--noreload"
12
],
13
"debugOptions": [
14
"WaitOnAbnormalExit",
15
"WaitOnNormalExit",
16
"RedirectOutput",
17
"DjangoDebugging"
18
]
19
},
20