美文网首页
vscode + venv + django

vscode + venv + django

作者: 剁椒鸡蛋zy | 来源:发表于2018-04-23 19:02 被阅读0次

在venv 环境下如何单步调试 django 项目

  1. 设置setting.json

点击首选项-> 设置 打开setting.json 文件

{
    "python.venvPath": "/Users/apple/python_workspace/venv",
    "window.zoomLevel": 1,
    "python.pythonPath": "/Users/apple/python_workspace/venv/bin/python3.6",
    "editor.renderWhitespace": "all",
    "files.exclude": {
        "**/.git": false,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/*.pyc":true
    },
    "python.linting.pylintArgs": [
        "--load-plugins",
        "pylint_django"
    ],
    "explorer.confirmDragAndDrop": false
}

找到自己设置的venv环境的python地址,按照上面代码所示,修改
venvPathpython.Path,完成后重启vscode,
然后 查看-> 命令面板->搜索Select Interpreter选择刚才设置的Python。

  1. 配置launch.json

点击调试->添加配置->

 {
            "name": "Diango",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config:python.pythonPath}",
            "program": "${workspaceRoot}/manage.py",
            "cwd": "${workspaceRoot}",
            "args": [
                "runserver",
                "--noreload",
                "--nothreading"
            ],
            "env": {},
            "envFile": "${workspaceRoot}/../venv",  
        },

相关文章

网友评论

      本文标题:vscode + venv + django

      本文链接:https://www.haomeiwen.com/subject/sgnllftx.html