在 pyCharm 中,我们有这个选项,我们可以在其中配置
Run button
通过将服务器添加到脚本路径来启动服务器。
我想在 visual studio code 中做同样的事情,这样每当我点击运行时,我的 django 服务器就会启动。
You need to create a
launch.json
in the folder .vscode
which sits in the same folder as your manage.py
.
// 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: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}\\manage.py",
"args": [
"runserver",
],
"django": true
},
]
}
您可以通过单击
run & debug
创建一个,然后在顶部菜单绿色三角形单击 add configuration
-> python
-> Django