Spaces:
Sleeping
Sleeping
Update core/settings.py
Browse files- core/settings.py +68 -18
core/settings.py
CHANGED
|
@@ -1,13 +1,5 @@
|
|
| 1 |
"""
|
| 2 |
Django settings for core project.
|
| 3 |
-
|
| 4 |
-
Generated by 'django-admin startproject' using Django 5.2.8.
|
| 5 |
-
|
| 6 |
-
For more information on this file, see
|
| 7 |
-
https://docs.djangoproject.com/en/5.2/topics/settings/
|
| 8 |
-
|
| 9 |
-
For the full list of settings and their values, see
|
| 10 |
-
https://docs.djangoproject.com/en/5.2/ref/settings/
|
| 11 |
"""
|
| 12 |
|
| 13 |
from pathlib import Path
|
|
@@ -19,21 +11,23 @@ load_dotenv()
|
|
| 19 |
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
| 20 |
BASE_DIR = Path(__file__).resolve().parent.parent
|
| 21 |
|
| 22 |
-
|
| 23 |
-
# Quick-start development settings - unsuitable for production
|
| 24 |
-
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
|
| 25 |
-
|
| 26 |
# SECURITY WARNING: keep the secret key used in production secret!
|
| 27 |
-
SECRET_KEY = 'django-insecure-yfg#m4w$m&#igix9$bx87f#*gxsd=(l#y_i@ig16-5ug^g3a-k'
|
| 28 |
|
| 29 |
# SECURITY WARNING: don't run with debug turned on in production!
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
ALLOWED_HOSTS = []
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
# Application definition
|
| 36 |
-
|
| 37 |
INSTALLED_APPS = [
|
| 38 |
'whitenoise.runserver_nostatic',
|
| 39 |
'django.contrib.admin',
|
|
@@ -48,7 +42,7 @@ INSTALLED_APPS = [
|
|
| 48 |
]
|
| 49 |
|
| 50 |
MIDDLEWARE = [
|
| 51 |
-
'corsheaders.middleware.CorsMiddleware',
|
| 52 |
'django.middleware.security.SecurityMiddleware',
|
| 53 |
'whitenoise.middleware.WhiteNoiseMiddleware',
|
| 54 |
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
@@ -78,6 +72,62 @@ TEMPLATES = [
|
|
| 78 |
|
| 79 |
WSGI_APPLICATION = 'core.wsgi.application'
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
# Database
|
| 83 |
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
|
|
|
|
| 1 |
"""
|
| 2 |
Django settings for core project.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
"""
|
| 4 |
|
| 5 |
from pathlib import Path
|
|
|
|
| 11 |
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
| 12 |
BASE_DIR = Path(__file__).resolve().parent.parent
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
# SECURITY WARNING: keep the secret key used in production secret!
|
| 15 |
+
SECRET_KEY = os.getenv('SECRET_KEY', 'django-insecure-yfg#m4w$m&#igix9$bx87f#*gxsd=(l#y_i@ig16-5ug^g3a-k')
|
| 16 |
|
| 17 |
# SECURITY WARNING: don't run with debug turned on in production!
|
| 18 |
+
# En Hugging Face, si no pones la variable DEBUG=True en Settings, será False por defecto.
|
| 19 |
+
DEBUG = os.getenv('DEBUG', 'False') == 'True'
|
|
|
|
| 20 |
|
| 21 |
+
# --- CONFIGURACIÓN DE HOSTS (Crucial para evitar Bad Request) ---
|
| 22 |
+
ALLOWED_HOSTS = [
|
| 23 |
+
'localhost',
|
| 24 |
+
'127.0.0.1',
|
| 25 |
+
'.hf.space', # Para Hugging Face
|
| 26 |
+
'.onrender.com', # Para Render (si lo usas)
|
| 27 |
+
'fintech-coop-ai.onrender.com'
|
| 28 |
+
]
|
| 29 |
|
| 30 |
# Application definition
|
|
|
|
| 31 |
INSTALLED_APPS = [
|
| 32 |
'whitenoise.runserver_nostatic',
|
| 33 |
'django.contrib.admin',
|
|
|
|
| 42 |
]
|
| 43 |
|
| 44 |
MIDDLEWARE = [
|
| 45 |
+
'corsheaders.middleware.CorsMiddleware', # Siempre primero
|
| 46 |
'django.middleware.security.SecurityMiddleware',
|
| 47 |
'whitenoise.middleware.WhiteNoiseMiddleware',
|
| 48 |
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
|
|
| 72 |
|
| 73 |
WSGI_APPLICATION = 'core.wsgi.application'
|
| 74 |
|
| 75 |
+
# Database
|
| 76 |
+
DATABASES = {
|
| 77 |
+
'default': {
|
| 78 |
+
'ENGINE': 'django.db.backends.sqlite3',
|
| 79 |
+
'NAME': BASE_DIR / 'db.sqlite3',
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
# Password validation
|
| 84 |
+
AUTH_PASSWORD_VALIDATORS = [
|
| 85 |
+
{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'},
|
| 86 |
+
{'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator'},
|
| 87 |
+
{'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'},
|
| 88 |
+
{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'},
|
| 89 |
+
]
|
| 90 |
+
|
| 91 |
+
# Internationalization
|
| 92 |
+
LANGUAGE_CODE = 'en-us'
|
| 93 |
+
TIME_ZONE = 'UTC'
|
| 94 |
+
USE_I18N = True
|
| 95 |
+
USE_TZ = True
|
| 96 |
+
|
| 97 |
+
# Static files (WhiteNoise)
|
| 98 |
+
STATIC_URL = 'static/'
|
| 99 |
+
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
|
| 100 |
+
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
| 101 |
+
|
| 102 |
+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
| 103 |
+
|
| 104 |
+
# --- CONFIGURACIÓN DE CORS (Para conectar con Vercel) ---
|
| 105 |
+
CORS_ALLOW_ALL_ORIGINS = True # Permite conexiones desde cualquier origen (Vercel, Local, etc.)
|
| 106 |
+
CORS_ALLOW_HEADERS = ["*"]
|
| 107 |
+
|
| 108 |
+
# --- CONFIGURACIÓN DE CSRF (Para formularios y POST) ---
|
| 109 |
+
CSRF_TRUSTED_ORIGINS = [
|
| 110 |
+
"https://fintech-coop-ai.vercel.app",
|
| 111 |
+
"https://fintech-coop-or6mski9z-tomasgonzalezpy-4881s-projects.vercel.app",
|
| 112 |
+
"https://*.hf.space"
|
| 113 |
+
]
|
| 114 |
+
TEMPLATES = [
|
| 115 |
+
{
|
| 116 |
+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
| 117 |
+
'DIRS': [],
|
| 118 |
+
'APP_DIRS': True,
|
| 119 |
+
'OPTIONS': {
|
| 120 |
+
'context_processors': [
|
| 121 |
+
'django.template.context_processors.request',
|
| 122 |
+
'django.contrib.auth.context_processors.auth',
|
| 123 |
+
'django.contrib.messages.context_processors.messages',
|
| 124 |
+
],
|
| 125 |
+
},
|
| 126 |
+
},
|
| 127 |
+
]
|
| 128 |
+
|
| 129 |
+
WSGI_APPLICATION = 'core.wsgi.application'
|
| 130 |
+
|
| 131 |
|
| 132 |
# Database
|
| 133 |
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
|