mirror of
https://github.com/Django-LiveView/demo-alarms
synced 2026-01-08 06:23:32 +01:00
Real-time alert system using Django LiveView with WebSocket support. Features include: - Real-time alert creation, viewing, and deletion - Broadcast notifications to all connected users - SQLite database - Stimulus.js integration for interactive UI - Modal dialogs for alert details - Alert form with validation Fixed Stimulus controller scope issue by placing data-controller on html element.
99 lines
2.5 KiB
Python
99 lines
2.5 KiB
Python
import os
|
|
from pathlib import Path
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
SECRET_KEY = os.environ.get('SECRET_KEY', 'django-insecure-demo-key-change-in-production')
|
|
|
|
DEBUG = os.environ.get('DEBUG', 'True').lower() == 'true'
|
|
|
|
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '*').split(',')
|
|
|
|
INSTALLED_APPS = [
|
|
'daphne',
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'channels',
|
|
'liveview',
|
|
'alerts.apps.AlertsConfig',
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
'django.middleware.security.SecurityMiddleware',
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
'django.middleware.common.CommonMiddleware',
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
]
|
|
|
|
ROOT_URLCONF = 'config.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [BASE_DIR / 'templates'],
|
|
'APP_DIRS': True,
|
|
'OPTIONS': {
|
|
'context_processors': [
|
|
'django.template.context_processors.debug',
|
|
'django.template.context_processors.request',
|
|
'django.contrib.auth.context_processors.auth',
|
|
'django.contrib.messages.context_processors.messages',
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = 'config.wsgi.application'
|
|
ASGI_APPLICATION = 'config.asgi.application'
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': BASE_DIR / 'db.sqlite3',
|
|
}
|
|
}
|
|
|
|
CHANNEL_LAYERS = {
|
|
'default': {
|
|
'BACKEND': 'channels_redis.core.RedisChannelLayer',
|
|
'CONFIG': {
|
|
'hosts': [(os.environ.get('REDIS_HOST', 'redis'), 6379)],
|
|
},
|
|
},
|
|
}
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
},
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
},
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
},
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
},
|
|
]
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
TIME_ZONE = 'UTC'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_TZ = True
|
|
|
|
STATIC_URL = '/static/'
|
|
STATIC_ROOT = BASE_DIR / 'staticfiles'
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|