Reputation: 43
I'm trying to launch my Django application using VS codes debugger. I need to run the command 'hatch shell' to enter my hatch development environment before running the server command 'py manage.py runserver'. I can't find out how to do this using the VS code debugger profile specified in the launch.json file below.
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Django",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/testproject/manage.py",
"args": [
"runserver"
],
"django": true,
"justMyCode": true
}
]
}
I tried to run 'hatch shell' as a preLaunchTask but that runserver command did not run in the shell environment.
Helpful resources: https://code.visualstudio.com/docs/python/tutorial-django#_create-a-debugger-launch-profile
https://code.visualstudio.com/docs/python/debugging
Upvotes: 1
Views: 247
Reputation: 171
In Hatch projects I use VSCODE launch configurations property envFile
...
"envFile": "${workspaceRoot}/.env",
...
Then in the .env file add:
PATH="<HATCH ENV PATH>:${PATH}"
Use the following command to find the path:
hatch env find hatch-test
Upvotes: 1