Debuging Django Manage.py Custom commands Pycharm

I am trying to learn how to debug a django application with PyCharm. In the application we have several custom manage.py commands. If I run there via terminal (external or Pycharm's terminal) they run fine.

If I try to run them from PyCharm (Tool -> run manage.py task) so I can debug, I get the following error:

Unknown command: 'add_question'
Type 'manage.py help' for usage.

I started working on the Django Project before using PyCharm, so I created it via django-admin, and we are adding it to pycharm as OpenDirectory->Select the project.

Any help would be helpful, be it to manage to run the command from inside PyCharm, or to connect PyCharms terminal to the debugger so that I can debug when running from PyCharms terminal.


The solution is in another answer, though a little outdated. Quick update for PyCharm 2016.3:

  • Run > Run... > Edit Configurations... (Note: you can add configurations by doing both "Run..." and "Debug...")
  • Click green + (plus sign)
  • In the drop down menu, choose Django Server.
  • Check "Custom run command" and enter your command (the part that goes after manage.py in the console.
  • Make sure "Port" and "Host" are empty. If not—make them empty.
  • Change "Name" to your liking.
  • "Apply" and "Close"
  • 在这里输入图像描述

    Now you can run this configuration (Run > Run... > Your_configuration_name) and debug it (Run > Debug... > Your_configuration_name).


    You can create a configuration for a custom command you made

  • Select Tools->Edit Configurations.
  • In the left column, you will find a list and a "+" button in the upper part. Click this one, then select "Django Server.
  • In the right part of the same window, you check "Custom run command", and write your custom command in the box
  • Write a name for this configuration and select OK.
  • Now just run/debug, selecting the configuration you just created.


    for anyone still having trouble with this. Try setting up a python run configuration which is more flexible instead of django server configuration. Checkout this post

    链接地址: http://www.djcxy.com/p/44944.html

    上一篇: 用Flask和PyCharm调试JavaScript

    下一篇: 调试Django Manage.py自定义命令Pycharm