178 lines
4.9 KiB
Python
178 lines
4.9 KiB
Python
from pathlib import Path
|
|
import os
|
|
import dj_database_url
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
BASE_URL = "https://app.polisplexity.tech"
|
|
|
|
import sys
|
|
sys.path.append(str(BASE_DIR))
|
|
|
|
|
|
# Core security settings
|
|
SECRET_KEY = os.getenv("SECRET_KEY")
|
|
DEBUG = os.getenv("DEBUG", "False") == "True"
|
|
ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS", "").split(",")
|
|
|
|
# Application definition
|
|
INSTALLED_APPS = [
|
|
# Django built-in apps
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
"django.contrib.sites", # Required for allauth
|
|
|
|
# Allauth
|
|
"allauth",
|
|
"allauth.account",
|
|
"allauth.socialaccount",
|
|
"allauth.socialaccount.providers.github", # GitHub login only
|
|
|
|
# Your custom apps
|
|
"core",
|
|
"pxy_de",
|
|
"pxy_cr",
|
|
"pxy_whatsapp",
|
|
"pxy_city_digital_twins",
|
|
"pxy_bots",
|
|
"pxy_openai",
|
|
"pxy_meta_pages",
|
|
"pxy_langchain",
|
|
"pxy_neo4j",
|
|
"pxy_dashboard",
|
|
"pxy_dashboard.custom",
|
|
"pxy_dashboard.apps",
|
|
"pxy_dashboard.components",
|
|
"pxy_dashboard.layouts",
|
|
|
|
# Third-party apps
|
|
"crispy_forms",
|
|
"crispy_bootstrap5",
|
|
|
|
]
|
|
|
|
CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
|
|
CRISPY_TEMPLATE_PACK = "bootstrap5"
|
|
|
|
SITE_ID = int(os.getenv("SITE_ID", 1))
|
|
|
|
AUTHENTICATION_BACKENDS = [
|
|
"django.contrib.auth.backends.ModelBackend", # default
|
|
"allauth.account.auth_backends.AuthenticationBackend", # allauth support
|
|
]
|
|
|
|
LOGIN_REDIRECT_URL = "/"
|
|
ACCOUNT_LOGOUT_REDIRECT_URL = "/accounts/login/"
|
|
|
|
|
|
MIDDLEWARE = [
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
"django.middleware.common.CommonMiddleware",
|
|
"django.middleware.csrf.CsrfViewMiddleware",
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
"allauth.account.middleware.AccountMiddleware",
|
|
"pxy_dashboard.middleware.LoginRequiredMiddleware",
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
]
|
|
|
|
ROOT_URLCONF = "polisplexity.urls"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [
|
|
os.path.join(BASE_DIR, "templates"),
|
|
os.path.join(BASE_DIR, "pxy_dashboard", "templates"),
|
|
],
|
|
"APP_DIRS": True,
|
|
"OPTIONS": {
|
|
"context_processors": [
|
|
"django.template.context_processors.debug",
|
|
"django.template.context_processors.request",
|
|
"django.contrib.auth.context_processors.auth",
|
|
"django.contrib.messages.context_processors.messages",
|
|
"pxy_dashboard.context_processors.sidebar_context",
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
|
|
|
|
WSGI_APPLICATION = "polisplexity.wsgi.application"
|
|
|
|
# Database
|
|
DATABASES = {
|
|
"default": dj_database_url.config(default=os.getenv("DATABASE_URL"))
|
|
}
|
|
|
|
# Password validation
|
|
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"},
|
|
]
|
|
|
|
# Internationalization
|
|
LANGUAGE_CODE = "en-us"
|
|
TIME_ZONE = "UTC"
|
|
USE_I18N = True
|
|
USE_TZ = True
|
|
|
|
# Static & Media Files
|
|
STATIC_URL = "/static/"
|
|
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
|
|
|
|
STATICFILES_DIRS = [
|
|
os.path.join(BASE_DIR, "polisplexity/pxy_dashboard/static"), # Jidox assets
|
|
]
|
|
|
|
MEDIA_URL = "/media/"
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, "mediafiles")
|
|
|
|
# Default primary key field type
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
|
|
# External services
|
|
PAGE_ACCESS_TOKEN = os.getenv("PAGE_ACCESS_TOKEN")
|
|
VERIFY_TOKEN = os.getenv("VERIFY_TOKEN")
|
|
|
|
# Async-safe for Neo4j or Celery
|
|
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
|
|
# ...pero silenciamos la comprobación que falla en producción:
|
|
SILENCED_SYSTEM_CHECKS = ["async.E001"]
|
|
|
|
# Neo4j
|
|
NEO4J_URI = os.getenv("NEO4J_URI")
|
|
NEO4J_USERNAME = os.getenv("NEO4J_USERNAME")
|
|
NEO4J_PASSWORD = os.getenv("NEO4J_PASSWORD")
|
|
|
|
# OpenAI
|
|
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
|
|
|
# CSRF protection for production
|
|
CSRF_TRUSTED_ORIGINS = [
|
|
"https://app.polisplexity.tech",
|
|
]
|
|
|
|
# Support for secure reverse proxy (e.g., Nginx or Hostinger HTTPS proxy)
|
|
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
|
|
|
|
|
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
|
|
EMAIL_HOST = "smtp.hostinger.com"
|
|
EMAIL_PORT = 465
|
|
EMAIL_USE_SSL = True
|
|
EMAIL_HOST_USER = "noreply@polisplexity.tech" # Cambia esto por tu correo real
|
|
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD") # Mejor usar .env
|
|
DEFAULT_FROM_EMAIL = "Polisplexity <noreply@polisplexity.tech>"
|