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 命令
基础教程推荐
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
