| from pathlib import Path |
| from dotenv import load_dotenv |
| import os |
|
|
| load_dotenv() |
|
|
| DEVELOPMENT = os.getenv("DEVELOPMENT") |
|
|
| DEBUG = True |
|
|
|
|
| if DEVELOPMENT == "local": |
| |
| DEBUG = True |
| print("Running in local development mode") |
| DATABASES = { |
| "default": { |
| "ENGINE": "django.db.backends.postgresql", |
| "NAME": os.getenv("DB_NAME_LOCAL"), |
| "USER": os.getenv("DB_USER_LOCAL"), |
| "PASSWORD": os.getenv("DB_PASS_LOCAL"), |
| "HOST": os.getenv("DB_HOST_LOCAL"), |
| "PORT": os.getenv("DB_PORT_LOCAL", "5432"), |
| } |
| } |
| SITE_URL = "http://localhost:8000" |
|
|
| else: |
| |
| DEBUG = True |
| print("Running in live production mode") |
| DATABASES = { |
| "default": { |
| "ENGINE": "django.db.backends.postgresql", |
| "NAME": os.getenv("DB_NAME_LIVE"), |
| "USER": os.getenv("DB_USER_LIVE"), |
| "PASSWORD": os.getenv("DB_PASS_LIVE"), |
| "HOST": os.getenv("DB_HOST_LIVE"), |
| "PORT": "", |
| "OPTIONS": { |
| "sslmode": "require", |
| }, |
| } |
| } |
| SITE_URL = "https://coders813-my-space2.hf.space/" |
|
|
| BASE_DIR = Path(__file__).resolve().parent.parent |
|
|
| SECRET_KEY = os.getenv("SECRET_KEY") |
|
|
| ALLOWED_HOSTS = ["*"] |
|
|
| INSTALLED_APPS = [ |
| "django.contrib.admin", |
| "django.contrib.auth", |
| "django.contrib.contenttypes", |
| "django.contrib.sessions", |
| "django.contrib.messages", |
| "django.contrib.staticfiles", |
| "rest_framework", |
| "api", |
| "corsheaders", |
| "drf_spectacular", |
| ] |
|
|
| 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", |
| "corsheaders.middleware.CorsMiddleware", |
| ] |
|
|
| ROOT_URLCONF = "expensewise_api.urls" |
|
|
| TEMPLATES = [ |
| { |
| "BACKEND": "django.template.backends.django.DjangoTemplates", |
| "DIRS": [], |
| "APP_DIRS": True, |
| "OPTIONS": { |
| "context_processors": [ |
| "django.template.context_processors.request", |
| "django.contrib.auth.context_processors.auth", |
| "django.contrib.messages.context_processors.messages", |
| ], |
| }, |
| }, |
| ] |
|
|
| WSGI_APPLICATION = "expensewise_api.wsgi.application" |
|
|
| 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 = "Asia/Kolkata" |
|
|
| USE_I18N = True |
|
|
| USE_TZ = True |
|
|
| STATIC_URL = "static/" |
|
|
| DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" |
|
|
| STATIC_ROOT = os.path.join(BASE_DIR, "static") |
|
|
| CSRF_TRUSTED_ORIGINS = ["https://*.hf.space"] |
|
|
| CORS_ALLOWED_ORIGINS = [ |
| "http://127.0.0.1:5500", |
| "http://localhost:3000", |
| "https://*.hf.space", |
| ] |
|
|
| CORS_ALLOW_ALL_ORIGINS = True |
|
|
| CSRF_TRUSTED_ORIGINS = [ |
| "https://*.hf.space", |
| ] |
|
|
|
|
| REST_FRAMEWORK = { |
| "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema", |
| } |
|
|
| SPECTACULAR_SETTINGS = { |
| "TITLE": "Expense Wise API", |
| "DESCRIPTION": "API documentation for my project", |
| "VERSION": "1.0.0", |
| "SERVE_INCLUDE_SCHEMA": False, |
| } |
|
|