Using DevContainers and VSCode for python and django #16
Replies: 3 comments
-
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.
-
Migrating from ruff-lspRuff settings have been updated, so devcontainers using ruff need to switch from: {
"customizations": {
"vscode": {
"settings": {
// ...
"ruff.format.args": ["--line-length", "120"], to {
"customizations": {
"vscode": {
"settings": {
// ...
"ruff.lineLength":120, |
Beta Was this translation helpful? Give feedback.
-
Update for using non-VSCode devcontainer imagesThis line is in many of our
ProblemIt (usually?) works if you're using a microsoft based image, but if you need to use something else, the devcontainer won't launch, citing SolutionThe solution is to set the
|
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