Compare commits
2 Commits
main
..
aa84422d10
| Author | SHA1 | Date | |
|---|---|---|---|
| aa84422d10 | |||
| ceff3cc1a0 |
+15
-33
@@ -1,10 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import dj_database_url
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import cloudinary
|
|
||||||
import cloudinary.uploader
|
|
||||||
import cloudinary.api
|
|
||||||
|
|
||||||
# Load .env file (for local dev only, Render will use Environment tab)
|
# Load .env file (for local dev only, Render will use Environment tab)
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
@@ -12,9 +8,9 @@ load_dotenv()
|
|||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
# Security
|
# Security
|
||||||
SECRET_KEY = os.getenv("SECRET_KEY", "unsafe-secret-key")
|
SECRET_KEY = os.getenv("SECRET_KEY")
|
||||||
DEBUG = os.getenv("DEBUG", "False") == "True"
|
DEBUG = True
|
||||||
ALLOWED_HOSTS = ["*", "civicfix.onrender.com"]
|
ALLOWED_HOSTS = ["localhost", "127.0.0.1"]
|
||||||
|
|
||||||
# Installed apps
|
# Installed apps
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
@@ -24,19 +20,11 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.humanize',
|
'django.contrib.humanize',
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'cloudinary',
|
|
||||||
'cloudinary_storage',
|
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'whitenoise.runserver_nostatic',
|
'whitenoise.runserver_nostatic',
|
||||||
'core.apps.CoreConfig',
|
'core.apps.CoreConfig',
|
||||||
]
|
]
|
||||||
|
|
||||||
CLOUDINARY_STORAGE = {
|
|
||||||
'CLOUD_NAME': os.getenv('CLOUD_NAME'),
|
|
||||||
'API_KEY': os.getenv('API_KEY'),
|
|
||||||
'API_SECRET': os.getenv('API_SECRET'),
|
|
||||||
}
|
|
||||||
|
|
||||||
AUTH_USER_MODEL = 'core.User'
|
AUTH_USER_MODEL = 'core.User'
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
@@ -69,13 +57,16 @@ TEMPLATES = [
|
|||||||
|
|
||||||
WSGI_APPLICATION = 'civicfix.wsgi.application'
|
WSGI_APPLICATION = 'civicfix.wsgi.application'
|
||||||
|
|
||||||
# Database (Render Postgres, fallback to SQLite locally)
|
# Database (PostgreSQL for Local)
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
"default": dj_database_url.config(
|
'default': {
|
||||||
default=os.environ.get("DATABASE_URL"),
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
conn_max_age=600,
|
'NAME': os.getenv("DB_NAME"),
|
||||||
ssl_require=True,
|
'USER': os.getenv("DB_USER"),
|
||||||
)
|
'PASSWORD': os.getenv("DB_PASSWORD"),
|
||||||
|
'HOST': os.getenv("DB_HOST"),
|
||||||
|
'PORT': os.getenv("DB_PORT"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Password validators
|
# Password validators
|
||||||
@@ -86,6 +77,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'},
|
{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
LANGUAGE_CODE = 'en-us'
|
LANGUAGE_CODE = 'en-us'
|
||||||
TIME_ZONE = 'UTC'
|
TIME_ZONE = 'UTC'
|
||||||
@@ -96,18 +88,8 @@ USE_TZ = True
|
|||||||
STATIC_URL = "/static/"
|
STATIC_URL = "/static/"
|
||||||
STATIC_ROOT = BASE_DIR / "staticfiles"
|
STATIC_ROOT = BASE_DIR / "staticfiles"
|
||||||
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
||||||
|
MEDIA_URL = "/media/"
|
||||||
|
MEDIA_ROOT = BASE_DIR / "media"
|
||||||
cloudinary.config(
|
|
||||||
cloud_name=os.getenv("CLOUD_NAME"),
|
|
||||||
api_key=os.getenv("API_KEY"),
|
|
||||||
api_secret=os.getenv("API_SECRET"),
|
|
||||||
secure=True
|
|
||||||
)
|
|
||||||
|
|
||||||
# Default storage (Cloudinary)
|
|
||||||
DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage'
|
|
||||||
|
|
||||||
|
|
||||||
# Auth redirects
|
# Auth redirects
|
||||||
LOGIN_REDIRECT_URL = 'citizen_dashboard'
|
LOGIN_REDIRECT_URL = 'citizen_dashboard'
|
||||||
|
|||||||
Reference in New Issue
Block a user