Modified requirements and updated settings
This commit is contained in:
parent
52adf7191a
commit
637b112c4e
@ -13,7 +13,7 @@ https://docs.djangoproject.com/en/5.2/ref/settings/
|
||||
import os
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
from django.contrib.messages import constants as messages
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
load_dotenv()
|
||||
|
||||
@ -30,13 +30,34 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = os.getenv("DEBUG", "False") == "True"
|
||||
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY', 'fallback-secret-key-for-dev')
|
||||
SECRET_KEY = os.environ.get("SECRET_KEY")
|
||||
if not SECRET_KEY:
|
||||
if DEBUG:
|
||||
SECRET_KEY = "django-insecure-dev-only-fallback-key"
|
||||
else:
|
||||
raise ImproperlyConfigured(
|
||||
"SECRET_KEY no está definido. Es obligatorio en producción "
|
||||
"(DEBUG-False) - revisa el .env del despliegue en el NAS"
|
||||
)
|
||||
|
||||
|
||||
ALLOWED_HOSTS = [
|
||||
"finanzas.kuijper.es",
|
||||
h.strip()
|
||||
for h in os.environ.get("ALLOWED_HOSTS", "localhost, 127.0.0.1").split(",")
|
||||
if h.strip()
|
||||
]
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = [
|
||||
o.strip()
|
||||
for o in os.environ.get("CSRF_TRUSTED_ORIGINS", "").split(",")
|
||||
if o.strip()
|
||||
]
|
||||
|
||||
if not DEBUG:
|
||||
SESSION_COOKIE_SECURE = True
|
||||
CSRF_COOKIE_SECURE = True
|
||||
SECURE_SSL_REDIRECT = True
|
||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
||||
|
||||
# Application definition
|
||||
|
||||
@ -52,6 +73,7 @@ INSTALLED_APPS = [
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
@ -83,6 +105,19 @@ WSGI_APPLICATION = 'expenses_manager.wsgi.application'
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
|
||||
|
||||
DB_ENGINE = os.environ.get("DB_ENGINE", "sqlite3")
|
||||
if DB_ENGINE == "postgresql":
|
||||
DATABASES = {
|
||||
'default': {
|
||||
"ENGINE": "django.db.backends.postgresql",
|
||||
"NAME": os.environ["DB_NAME"],
|
||||
"USER": os.environ["DB_USER"],
|
||||
"PASSWORD": os.environ["DB_PASSWORD"],
|
||||
"HOST": os.environ.get("DB_HOST", "localhost"),
|
||||
"PORT": os.environ.get("DB_PORT", "5432"),
|
||||
}
|
||||
}
|
||||
else:
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
@ -91,41 +126,39 @@ DATABASES = {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
|
||||
|
||||
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',
|
||||
},
|
||||
{'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
|
||||
# https://docs.djangoproject.com/en/5.2/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
LANGUAGE_CODE = 'es'
|
||||
LANGUAGE_CODE = 'es'
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
DATE_INPUT_FORMATS = ["%d/%m/%Y"]
|
||||
DATETIME_INPUT_FORMATS = ["%d/%m/%Y %H:%M"]
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/5.2/howto/static-files/
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = BASE_DIR / 'staticfiles'
|
||||
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
|
||||
@ -135,3 +168,22 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
LOGIN_URL = 'login'
|
||||
LOGIN_REDIRECT_URL = 'home'
|
||||
LOGOUT_REDIRECT_URL = 'login'
|
||||
|
||||
LOGGING = {
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
"handlers": {
|
||||
"console": {"class": "logging.StreamHandler"},
|
||||
},
|
||||
"root": {
|
||||
"handlers": ["console"],
|
||||
"level": "WARNING",
|
||||
},
|
||||
"loggers": {
|
||||
"django": {
|
||||
"handlers": ["console"],
|
||||
"level": "INFO",
|
||||
"propagate": False,
|
||||
},
|
||||
},
|
||||
}
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user