My Django project is working properly when I am pressing pycharm's green play button. But when debug button is clicked, it says can't find '__main__' module in ''
.
I did little bit RCA and found __spec__
is being set on __main__
when running with the debug option.
Here is the relevant code degment from /lib/python3.8/site-packages/django/utils/autoreload.py
# __spec__ is set when the server was started with the `-m` option,
# see https://docs.python.org/3/reference/import.html#main-spec
# __spec__ may not exist, e.g. when running in a Conda env.
if getattr(__main__, '__spec__', None) is not None:
spec = __main__.__spec__
if (spec.name == '__main__' or spec.name.endswith('.__main__')) and spec.parent:
name = spec.parent
else:
name = spec.name
args += ['-m', name]
args += sys.argv[1:]
Please help me finding a workaround in order to use PyCharm's debug functionality.
Django version: 4.0.1
Python version: 3.8.6
PyCharm 2021.2 (Community Edition)