I am trying to use django-eventstream to implement SSE events. My code runs perfectly using manage.py runserver
on the local PC. However, when I run:
daphne config.asgi:application
on the production server, I get the following error:
File "./config/asgi.py", line 21, in <module>
url(r'', get_asgi_application()),
File "/home/bidforga/virtualenv/bfg/bfg_wag/3.7/lib/python3.7/site-packages/django/core/asgi.py", line 12, in get_asgi_application
django.setup(set_prefix=False)
File "/home/bidforga/virtualenv/bfg/bfg_wag/3.7/lib/python3.7/site-packages/django/__init__.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/home/bidforga/virtualenv/bfg/bfg_wag/3.7/lib/python3.7/site-packages/django/conf/__init__.py", line 82, in __getattr__
self._setup(name)
File "/home/bidforga/virtualenv/bfg/bfg_wag/3.7/lib/python3.7/site-packages/django/conf/__init__.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "/home/bidforga/virtualenv/bfg/bfg_wag/3.7/lib/python3.7/site-packages/django/conf/__init__.py", line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/home/bidforga/virtualenv/bfg/bfg_wag/3.7/lib64/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'server'
This is my config/asgi.py
import os
import django
from django.core.asgi import get_asgi_application
from django.conf.urls import url
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
import django_eventstream
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")
application = ProtocolTypeRouter({
'http': URLRouter([
url(r'^events/', AuthMiddlewareStack(
URLRouter(django_eventstream.routing.urlpatterns)
), { 'channels': ['test'] }),
url(r'', get_asgi_application()),
]),
})
I assume it's looking for server.settings but I have no idea how to solve this