""" Django settings for config project. Generated by 'django-admin startproject' using Django 3.2.8. For more information on this file, see https://docs.djangoproject.com/en/3.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.2/ref/settings/ """ from pathlib import Path import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-z465dl_(vk55hxbm0bj*mp-ok3!*=ssw#!$5s2nrxa!9j+67z+' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['zierle-training-staging.riezel.com', 'localhost', '127.0.0.1', '192.168.1.244'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # third-party 'channels', # as high as possible (channels overloads 'runserver', may conflict with e.g. whitenoise) 'rest_framework', 'corsheaders', 'drf_yasg', 'storages', 'django_extensions', 'django_tex', 'colorfield', 'django_celery_results', # local 'websocket', 'accounts', 'photo_log', 'api', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] CORS_ALLOWED_ORIGINS = [ 'http://localhost:3000', 'http://localhost:8080', 'http://192.168.1.244:8080', ] ROOT_URLCONF = 'config.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(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', ], }, }, { 'NAME': 'tex', 'BACKEND': 'django_tex.engine.TeXEngine', 'APP_DIRS': True, 'DIRS': [os.path.join(BASE_DIR, 'templates/')], }, ] LATEX_INTERPRETER = 'xelatex' TEMPLATE_DIRS = ( os.path.join(BASE_DIR, 'templates'), ) WSGI_APPLICATION = 'config.wsgi.application' ASGI_APPLICATION = 'config.asgi.application' # Database # https://docs.djangoproject.com/en/3.2/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'zierle_training_db', 'USER': 'zierle_training_db_user', 'PASSWORD': 'UI&hWG,El7G{A2c0n=qIULv:b', 'HOST': 'localhost', 'PORT': '5432', } } # Password validation # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators 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', }, ] AUTH_USER_MODEL = 'accounts.CustomUser' # Internationalization # https://docs.djangoproject.com/en/3.2/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'CET' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.2/howto/static-files/ # Default primary key field type # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' MINIO = True if MINIO: # MinIO S3 Object-Storage DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' #STATICFILES_STORAGE = 'storages.backends.s3boto3.S3StaticStorage' AWS_ACCESS_KEY_ID = 'zierle-training' AWS_SECRET_ACCESS_KEY = 'IMienQKx6B5foJRegqZnSTk9MsUjDvd4' AWS_STORAGE_BUCKET_NAME = 'zierle-training' AWS_S3_ENDPOINT_URL = 'https://minio.riezel.com' AWS_DEFAULT_ACL = 'public' MEDIA_URL = 'https://minio.riezel.com/zierle-training/' #STATIC_URL = 'https://minio.riezel.com/zierle-training/' AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'public, max-age=86400', } else: MEDIA_URL = 'media/' MEDIA_ROOT = BASE_DIR / 'media' STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, "static/") #STATICFILES_DIRS = [os.path.join(BASE_DIR, "static/")] # Celery # See https://docs.celeryq.dev/en/stable/django/first-steps-with-django.html CELERY_CACHE_BACKEND = 'default' CELERY_WORK_DIR = '/home/marc/www-staging/celery/' CELERY_BROKER_URL = 'redis://localhost:6378/1' CELERY_RESULT_BACKEND= 'redis://localhost:6378/1' CELERY_TIMEZONE = 'CET' CELERY_BROKER_TRANSPORT_OPTIONS = { 'visibility_timeout': 300, } # Redis Cache # See CACHES = { 'default': { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": "redis://127.0.0.1:6378/1", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", }, "KEY_PREFIX": "zierletraining", } } # Django Channels - Channel Layers Backend # See https://channels.readthedocs.io/en/stable/topics/channel_layers.html # See https://pypi.org/project/channels-redis/ for settings configuration CHANNEL_LAYERS = { "default": { "BACKEND": "channels_redis.core.RedisChannelLayer", "CONFIG": { "hosts": [("127.0.0.1", 6378)], "prefix": "asgi_zierle_training_staging:", "group_expiry": 7200, }, }, }