4

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.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
ylc
  • 199
  • 1
  • 3
  • 9
  • Have you enabled "Django Support" (Settings>Django Support) and set the paths for settings and manage? – rockingskier Apr 08 '14 at 11:39
  • Yes. I had several problems at first with PATHs and general configuration parameters I had missed, but they gave the the problems also in the terminal run. I think all these problems are solved as I can run from PyCharms terminal, I just cant to it graphically. – ylc Apr 08 '14 at 12:01

3 Answers3

5

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"

enter image description here

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

Community
  • 1
  • 1
texnic
  • 3,959
  • 4
  • 42
  • 75
1

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.

Emily
  • 316
  • 2
  • 9
0

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

Ken4scholars
  • 6,076
  • 2
  • 21
  • 38