How to debug Django commands in PyCharm(如何在 PyCharm 中调试 Django 命令)
问题描述
我知道如何使用 PyCharm 运行命令(工具 -> 运行 manage.py 任务),但我也想调试它们,包括我的命令和第三方应用程序的命令.
I know how to run commands with PyCharm (Tools -> Run manage.py Task), but I would like to debug them also, including my commands and third party app's commands.
推荐答案
您可以通过在运行/调试配置菜单上创建自定义 Django 服务器条目来调试 PyCharm 中的自定义 Django 管理/管理命令:
You can debug a custom Django admin/management command in PyCharm by creating a custom Django server entry on the Run/Debug Configuration menu:
- 点击
编辑配置.... - 单击加号并选择
Django 服务器. - 随意填写
Name,清除Host和Port字段,检查Custom run command并输入你的命令名称到复选框右侧. - 在单独的字段
Additional options中输入任何额外的命令行参数,而不是附加在运行命令中. - 点击确定.
- Click
Edit Configurations.... - Click the plus sign and choose
Django server. - Fill in the
Nameas you please, clear theHostandPortfields, checkCustom run commandand enter the name of your command to the right of the checkbox. - Enter any extra command-line arguments into the separate field
Additional options, not appended in the run command. - Click OK.
现在设置一个断点,从运行/调试配置"菜单中选择您的新配置,然后单击调试"按钮.等等!
Now set a breakpoint, choose your new configuration from the Run/Debug Configuration menu and click the Debug button. Et voilà!
这篇关于如何在 PyCharm 中调试 Django 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 PyCharm 中调试 Django 命令
基础教程推荐
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 求两个直方图的卷积 2022-01-01
- 包装空间模型 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
