无法使用VSCode调试DJANGO项目中的应用程序视图

8fq7wneg  于 2023-07-01  发布在  Go
关注(0)|答案(1)|浏览(122)

我使用DJANGO框架创建了一个应用程序来创建几个API程序。为此,我创建了一个应用程序,现在已在安装的应用程序列表中。
我可以manage.py在服务器启动时调试www.example.com文件。但是我不能调试应用程序中对视图的后续调用,views.py断点永远不会被命中?

然而,这是永远达不到的

这就是我的启动JSON的样子:

{
// 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",
            "--noreload"
        ],

        "env": {
            "DJANGO_SETTINGS_MODULE": "django-sql-project.settings"
          },

        "django": true,
        "justMyCode": true
    }
]

}
我的VS设置json看起来像这样:

{
"python.defaultInterpreterPath":"~//env//Scripts//python.exe",
"python.terminal.activateEnvironment": true,
"appService.zipIgnorePattern": [
    "__pycache__{,/**}",
    "*.py[cod]",
    "*$py.class",
    ".Python{,/**}",
    "build{,/**}",
    "develop-eggs{,/**}",
    "dist{,/**}",
    "downloads{,/**}",
    "eggs{,/**}",
    ".eggs{,/**}",
    "lib{,/**}",
    "lib64{,/**}",
    "parts{,/**}",
    "sdist{,/**}",
    "var{,/**}",
    "wheels{,/**}",
    "share/python-wheels{,/**}",
    "*.egg-info{,/**}",
    ".installed.cfg",
    "*.egg",
    "MANIFEST",
    ".env{,/**}",
    ".venv{,/**}",
    "env{,/**}",
    "venv{,/**}",
    "ENV{,/**}",
    "env.bak{,/**}",
    "venv.bak{,/**}",
    ".vscode{,/**}"
]

}

epfja78i

epfja78i1#

我想这为我解决了它。为了能够调试在主django项目中创建和安装的应用程序,您必须将其添加到launch.json

现在调试器只单步执行自定义应用程序视图:

相关问题