Развертывание django с помощью daphne
Я хочу поднять свой сервер django, выполнив эту команду в daphne:
daphne -b 0.0.0.0 -p 9001 core.asgi:application
И произошла эта ошибка:
Traceback (most recent call last):
File "/usr/local/bin/daphne", line 8, in <module>
sys.exit(CommandLineInterface.entrypoint())
File "/usr/local/lib/python3.8/site-packages/daphne/cli.py", line 171, in entrypoint
cls().run(sys.argv[1:])
File "/usr/local/lib/python3.8/site-packages/daphne/cli.py", line 233, in run
application = import_by_path(args.application)
File "/usr/local/lib/python3.8/site-packages/daphne/utils.py", line 17, in import_by_path
target = importlib.import_module(module_path)
File "/usr/local/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 843, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/./core/asgi.py", line 4, in <module>
from stream.routing import ws_urlpatterns
File "/app/./stream/routing.py", line 2, in <module>
from .consumers import OccurrenceConsumer
File "/app/./stream/consumers.py", line 5, in <module>
from .models import Occurrence
File "/app/./stream/models.py", line 5, in <module>
class Asset(models.Model):
File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 129, in __new__
app_config = apps.get_containing_app_config(module)
File "/usr/local/lib/python3.8/site-packages/django/apps/registry.py", line 260, in get_containing_app_config
self.check_apps_ready()
File "/usr/local/lib/python3.8/site-packages/django/apps/registry.py", line 137, in check_apps_ready
settings.INSTALLED_APPS
File "/usr/local/lib/python3.8/site-packages/django/conf/__init__.py", line 102, in __getattr__
self._setup(name)
File "/usr/local/lib/python3.8/site-packages/django/conf/__init__.py", line 82, 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.
по наблюдениям сервер не запускался.
Похоже, что модель или приложение не распознаются. вот мой INSTALLED_APPS:
INSTALLED_APPS = [
# my apps:
"accounts",
"api",
"sms",
"ticket",
"base",
"finances",
"stream",
"assistant",
# add apps:
"rest_framework",
"rest_framework_simplejwt",
"django_extensions",
"corsheaders",
"channels",
"daphne",
"drf_yasg",
"solo",
# base apps:
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
]
кто может мне помочь?!
После этого я хочу развернуть свой сервер с nginx. Я запускаю сервер с моими http и ws протоколами.