When I run daphne -b 0.0.0.0 -p 8000 --access-log=daphne.log config.asgi:application
I get Daphne ModuleNotFoundError: No module named 'app_name'
But when I run python3 manage.py runserver
it works normally?
When I remove app_1
from INSTALLED_APPS
it will show me ModuleNotFoundError: No module named 'app_2'
This is my folder structure:
project_name
│ __init__.py
│ manage.py
│
└───config
│ │ __init__.py
│ │ asgi.py
│ │ celery.py
│ │ urls.py
│ │ wsgi.py
│ │
│ └───settings
│ │
│ │ __init__.py
│ │ base.py
│ │ dev.py
│ │ prod.py
│
│
└───project_name
│ │ __init__.py
│ │
│ └───app_1
│ └───app_2
│ └───app_3
│
└───media
│
└───static
asgi.py
:
from django.core.asgi import get_asgi_application
django_asgi_app = get_asgi_application()
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from chat import routing
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.dev')
application = ProtocolTypeRouter({
'http': django_asgi_app,
'websocket': AuthMiddlewareStack(
URLRouter(
routing.websocket_urlpatterns
)
),
})
I had to append the folder where all my apps lie to the PYTHONPATH environment variable like so:
PYTHONPATH="${PYTHONPATH}:/project_name/project_name"