hi @KenWhitesell I getting same issue and tried the solution provided.
Im trying to run daphne for websocket but its failing and throwing same error like above with my project directory name. im attaching daphne error log for more info below.
Traceback (most recent call last):
File "/home/administrator/people/peoples/venv/bin/daphne", line 8, in <module>
sys.exit(CommandLineInterface.entrypoint())
File "/home/administrator/people/peoples/venv/lib/python3.8/site-packages/daphne/cli.py", line 170, in entrypoint
cls().run(sys.argv[1:])
File "/home/administrator/people/peoples/venv/lib/python3.8/site-packages/daphne/cli.py", line 232, in run
application = import_by_path(args.application)
File "/home/administrator/people/peoples/venv/lib/python3.8/site-packages/daphne/utils.py", line 12, in import_by_path
target = importlib.import_module(module_path)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/administrator/people/peoples/./peoples/asgi.py", line 6, in <module>
from chat.consumers import ChatRoomConsumer
File "/home/administrator/people/peoples/./chat/consumers.py", line 6, in <module>
from people.models import User
File "/home/administrator/people/peoples/./people/models.py", line 5, in <module>
Apr 18 11:48:03 35651.hostserv.eu python[119025]: from django.contrib.auth.models import AbstractUser
File "/home/administrator/people/peoples/venv/lib/python3.8/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/home/administrator/people/peoples/venv/lib/python3.8/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
Apr 18 11:48:03 35651.hostserv.eu python[119025]: class AbstractBaseUser(models.Model):
File "/home/administrator/people/peoples/venv/lib/python3.8/site-packages/django/db/models/base.py", line 107, in __new__
app_config = apps.get_containing_app_config(module)
File "/home/administrator/people/peoples/venv/lib/python3.8/site-packages/django/apps/registry.py", line 252, in get_containing_app_config
self.check_apps_ready()
File "/home/administrator/people/peoples/venv/lib/python3.8/site-packages/django/apps/registry.py", line 134, in check_apps_ready
settings.INSTALLED_APPS
File "/home/administrator/people/peoples/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 76, in __getattr__
self._setup(name)
File "/home/administrator/people/peoples/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 57, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. . You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Follwing is daphne file config
[Unit]
Description=WebSocket Daphne Service
After=network.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/home/administrator/people/peoples
ExecStart=/home/administrator/people/peoples/venv/bin/python /home/administrator/people/peoples/venv/bin/daphne -e ssl:8001:privateKey=/etc/letsencrypt/live/www.peoplestogether.com/privkey.pem:certKey=/etc/letsencrypt/live/www.peoplestogether.com/fullchain.pem peoples.asgi:application
Restart=on-failure
[Install]
WantedBy=multi-user.target
hope that helps