Using DevContainers and VSCode for python and django #16
Replies: 1 comment
-
Debugging / Launch profiles in VSCodeIn VSCode, you want to be able to use pytest to debug your tests, and (if developing a django application or library) your django application itself. This will involve setting up your test framework with pytest, but you should also set up launch profiles in VSCode. To do that: In django-gcp we have But, we want to use VSCode's built in debugging. To do that we create launch profiles: In {
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug Tests",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"django": true,
"purpose": ["debug-test"],
"console": "integratedTerminal",
"justMyCode": true, // Make this false to set breakpoints in third party code
"env": {"PYTEST_ADDOPTS": "--no-cov"}
},
{
"name": "Python: Django",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver"
],
"django": true,
"justMyCode": true // Make this false to set breakpoints in third party code
}
]
} Launching django from the debug tools in the sidebar now launches django in debug mode. You can make any requests to your local server you like and hte execution will stop at any breakpoints in your code. |
Beta Was this translation helpful? Give feedback.
-
Use this discussion to record tips and tricks for how to set up devcontainers and/or VSCode
Beta Was this translation helpful? Give feedback.
All reactions