From 0d98375b055b2782cd54779566ef50bd31411e1f Mon Sep 17 00:00:00 2001 From: Vlad Bogolin Date: Mon, 21 Aug 2023 15:04:53 +0000 Subject: [PATCH] Add settings.py file for cross-reference --- cross-reference/.gitignore | 2 +- .../crossreference/crossreference/settings.py | 99 +++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 cross-reference/crossreference/crossreference/settings.py diff --git a/cross-reference/.gitignore b/cross-reference/.gitignore index 6e8bcc9a..3d96ad2f 100644 --- a/cross-reference/.gitignore +++ b/cross-reference/.gitignore @@ -2,4 +2,4 @@ cross-reference-venv *db.sqlite3 __pycache__ migrations -settings.py +.env diff --git a/cross-reference/crossreference/crossreference/settings.py b/cross-reference/crossreference/crossreference/settings.py new file mode 100644 index 00000000..bcab63cf --- /dev/null +++ b/cross-reference/crossreference/crossreference/settings.py @@ -0,0 +1,99 @@ +import os +from dotenv import load_dotenv + +# Load environment variables from .env file +load_dotenv() + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = os.getenv('DJANGO_SECRET_KEY') + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = False + +ALLOWED_HOSTS = [] + +# Application definition +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'cr', +] + +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 = 'crossreference.urls' +WSGI_APPLICATION = 'crossreference.wsgi.application' +ASGI_APPLICATION = 'crossreference.asgi.application' + +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', + ], + }, + }, +] + +# Database +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': os.getenv('DB_NAME'), + 'USER': os.getenv('DB_USER'), + 'PASSWORD': os.getenv('DB_PASSWORD'), + 'HOST': 'localhost', + 'PORT': '3306', + } +} + +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', + }, +] + +# Internationalization +LANGUAGE_CODE = 'en-us' +TIME_ZONE = 'UTC' +USE_I18N = True +USE_L10N = True +USE_TZ = True + +# Static files (CSS, JavaScript, Images) +STATIC_URL = '/cr/static/' +STATICFILES_DIRS = [os.path.join(BASE_DIR, 'cr', 'static')] +STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') + +# Add any other settings you may need... +