如何在PyCharm中调试Django命令 [英] How to debug Django commands in PyCharm

查看:865
本文介绍了如何在PyCharm中调试Django命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用PyCharm(工具 - >运行manage.py Task)运行命令,但是我也想调试它们,包括我的命令和第三方应用程序的命令。

解决方案

您可以通过在运行/调试配置菜单上创建自定义Django服务器条目来调试PyCharm中的自定义Django管理/管理命令:




  • 点击编辑配置...

  • 点击加号选择 Django服务器

  • 按照您的要求填写名称 主机端口字段,
    检查自定义运行命令并在复选框的
    的右侧输入您的命令的名称。

  • 在单独的字段中输入任何额外的命令行参数 Additional选项,不附加在运行命令中。

  • 单击确定。



现在设置一个断点,从Run /调试配置菜单,然后单击调试按钮。 Etvoilà!


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.

解决方案

You can debug a custom Django admin/management command in PyCharm by creating a custom Django server entry on the Run/Debug Configuration menu:

  • Click Edit Configurations....
  • Click the plus sign and choose Django server.
  • Fill in the Name as you please, clear the Host and Port fields, check Custom run command and 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命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆