Reputation: 119
Need help to run django app with daphne in DEBUG mode with pycharm. Is there any way?
Upvotes: 3
Views: 1945
Reputation:
File: run_daphne.py
import sys
import os
import django
if __name__ == '__main__':
# insert here whatever commands you use to run daphne
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "your_app.settings")
sys.argv = ['daphne', 'your_app.asgi:application']
from daphne.cli import CommandLineInterface
django.setup()
CommandLineInterface.entrypoint()
We are essentially doing the same thing as daphne command line just from python. Now you can run this file with PyCharm debugger.
Note that if you are using Django-Channels the runserver
command will use daphne by default.
Upvotes: 6
Reputation: 401
You have to use the python debugger it will stop your code wherever you put this.
Some Code--
import pdb; pdb.set_trace()
--Some Code
It will stop execution here and to proceed use "n" one by one.
Upvotes: 0