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.
Just right-click any line in the editor and select the Debug <filename> command from the context menu. After the program has been suspended, use the debugger to get the information about the state of the program and how it changes during running.
In the Settings/Preferences dialog ( Ctrl+Alt+S ) under the Languages and Frameworks node, click Django. In this page, choose the desired Django project. In the Manage.py tasks section, specify the following: In the field Manage script, specify the desired manage.py script.
You can debug a custom Django admin/management command in PyCharm by creating a custom Django server entry on the Run/Debug Configuration menu:
Edit Configurations...
.Django server
.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.Additional options
, not appended in the run command. Now set a breakpoint, choose your new configuration from the Run/Debug Configuration menu and click the Debug button. Et voilà!
Since clearing Host and Port will not make the command run at all (PyCharm 5), the solution I found is to use a Python run configuration instead of a Django server. Fill Script
with your manage.py script, other parameters in Script Parameters
, and adjust your environment such as Working directory
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With