@@ -9,7 +9,8 @@ https://docs.djangoproject.com/en/5.2/topics/settings/ |
| 9 | For the full list of settings and their values, see | 9 | For the full list of settings and their values, see |
| 10 | https://docs.djangoproject.com/en/5.2/ref/settings/ | 10 | https://docs.djangoproject.com/en/5.2/ref/settings/ |
| 11 | """ | 11 | """ |
| 12 | - | 12 | +import os |
| | 13 | +import dj_database_url |
| 13 | from pathlib import Path | 14 | from pathlib import Path |
| 14 | | 15 | |
| 15 | # Build paths inside the project like this: BASE_DIR / 'subdir'. | 16 | # Build paths inside the project like this: BASE_DIR / 'subdir'. |
@@ -25,8 +26,22 @@ SECRET_KEY = "django-insecure-xykf5$__a(xn*avfxs2njr#==cn7*+t8kg+4_lbi$(#+@5_j8g |
| 25 | # SECURITY WARNING: don't run with debug turned on in production! | 26 | # SECURITY WARNING: don't run with debug turned on in production! |
| 26 | DEBUG = True | 27 | DEBUG = True |
| 27 | | 28 | |
| 28 | -ALLOWED_HOSTS = [] | 29 | +ALLOWED_HOSTS = [ |
| | 30 | + 'localhost', |
| | 31 | + '127.0.0.1', |
| | 32 | + '.railway.app', |
| | 33 | + '.up.railway.app', |
| | 34 | +] |
| | 35 | + |
| | 36 | +# Database - Railway provides DATABASE_URL automatically |
| | 37 | +if os.environ.get('DATABASE_URL'): |
| | 38 | + DATABASES = { |
| | 39 | + 'default': dj_database_url.parse(os.environ.get('DATABASE_URL')) |
| | 40 | + } |
| 29 | | 41 | |
| | 42 | +# Static files |
| | 43 | +STATIC_URL = '/static/' |
| | 44 | +STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') |
| 30 | | 45 | |
| 31 | # Application definition | 46 | # Application definition |
| 32 | | 47 | |
@@ -52,6 +67,7 @@ MIDDLEWARE = [ |
| 52 | "django.middleware.clickjacking.XFrameOptionsMiddleware", | 67 | "django.middleware.clickjacking.XFrameOptionsMiddleware", |
| 53 | 'corsheaders.middleware.CorsMiddleware', | 68 | 'corsheaders.middleware.CorsMiddleware', |
| 54 | 'django.middleware.common.CommonMiddleware', | 69 | 'django.middleware.common.CommonMiddleware', |
| | 70 | + "whitenoise.middleware.WhiteNoiseMiddleware", |
| 55 | ] | 71 | ] |
| 56 | | 72 | |
| 57 | ROOT_URLCONF = "bashamole.urls" | 73 | ROOT_URLCONF = "bashamole.urls" |
@@ -135,4 +151,7 @@ CORS_ALLOWED_ORIGINS = [ |
| 135 | REST_FRAMEWORK = { | 151 | REST_FRAMEWORK = { |
| 136 | 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', | 152 | 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', |
| 137 | 'PAGE_SIZE': 100 | 153 | 'PAGE_SIZE': 100 |
| 138 | -} | 154 | +} |
| | 155 | + |
| | 156 | +if os.environ.get('FRONTEND_URL'): |
| | 157 | + CORS_ALLOWED_ORIGINS.append(os.environ.get('FRONTEND_URL')) |