How to use visual studio code to debug django

2019-03-09 17:04发布

I'm new at django development and come from desktop/mobile app development with Xcode and related IDE.

I have to use Django and I was wondering if there was an efficient way to debug it using Visual Studio Code (or Atom).

Any help related to Django IDE would be helpful too.

2条回答
仙女界的扛把子
2楼-- · 2019-03-09 17:24

Only experimental configuration works for me.

{ "name": "Django", "type": "pythonExperimental", "request": "launch", "program": "${workspaceFolder}/manage.py", "args": [ "runserver", "--noreload", "--nothreading" ], "django": true },

Standard config causes Unverified breakpoint issue.

查看更多
家丑人穷心不美
3楼-- · 2019-03-09 17:27

For VSCode (full disclosure, I'm one of the VSCode developers) try installing the Python extension to get started.

This documentation covers debugging Django. There should be a included debug configuration or you can add your own to the launch.json file:

{
    "name": "Django",
    "type": "python",
    "request": "launch",
    "stopOnEntry": false,
    "pythonPath": "${config.python.pythonPath}",
    "program": "${workspaceRoot}/manage.py",
    "args": [
        "runserver",
        "--no-color",
        "--noreload"
    ],
    "debugOptions": [
        "WaitOnAbnormalExit",
        "WaitOnNormalExit",
        "RedirectOutput",
        "DjangoDebugging"
    ]
}

The Python extension also provide many other features that you may find useful.

Hope that helps you get started.

查看更多
登录 后发表回答