I have been trying to deploy my application on heroku with django channels and I always get the following error
2022-05-26T20:09:58.137436+00:00 app[web.1]: ModuleNotFoundError: No module named 'core'
I have seen previous questions such as Deploying asgi and wsgi on Heroku but even when following these steps I can't get the deployment to work.
My channel layers in settings.py:
ASGI_APPLICATION = "server.asgi.application"
CHANNEL_LAYERS = {
'default': {
"BACKEND": "asgi_redis.RedisChannelLayer",
"CONFIG": {
"hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')]
},
'ROUTING': 'server.routing.channel_routing',
}
}
My asgi.py:
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
application = get_asgi_application()
My wsgi.py file
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
application = get_wsgi_application()
My Procfile
web: daphne server.asgi:channel_layer --port $PORT --bind 0.0.0.0 -v2
chatworker: python manage.py runworker --settings=server.settings -v2
My file structure
server
|
|_ _ chat
| |
| |_ __init__.py
| |
| |_ admin.py
| |
| |_ consumers.py
| |
| |_ models.py
| |
| |_ routing.py
| |
| |_ urls.py
| |
| |_ views.py
|_ _ server
| |
| |_ __init__.py
| |
| |_ asgi.py.py
| |
| |_ routing.py
| |
| |_ settings.py
| |
| |_ urls.py
| |
| |_ wsgi.py
|
|_ _ manage.py
|
|_ _ Procfile
|
|_ _ requirements.txt
My requirements.txt file:
aioredis==1.3.1
asgi-redis==1.1.0
asgiref==3.5.2
async-timeout==4.0.2
attrs==21.4.0
autobahn==22.4.2
Automat==20.2.0
cffi==1.15.0
channels==3.0.4
channels-redis==3.4.0
constantly==15.1.0
coverage==6.4
cryptography==37.0.2
daphne==3.0.2
Deprecated==1.2.13
dj-database-url==0.5.0
Django==4.0.4
django-cors-headers==3.12.0
django-on-heroku==1.1.2
djangorestframework==3.13.1
gunicorn==20.1.0
hiredis==2.0.0
hyperlink==21.0.0
idna==3.3
incremental==21.3.0
msgpack==1.0.3
msgpack-python==0.5.6
packaging==21.3
psycopg2==2.9.3
psycopg2-binary==2.9.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
PyJWT==2.4.0
pyOpenSSL==22.0.0
pyparsing==3.0.9
pytz==2022.1
redis==4.3.1
service-identity==21.1.0
six==1.16.0
sqlparse==0.4.2
Twisted==22.4.0
txaio==22.2.1
typing_extensions==4.2.0
tzdata==2022.1
whitenoise==6.1.0
wrapt==1.14.1
zope.interface==5.4.0