""" Django settings for backend project. Generated by 'django-admin startproject' using Django 5.1.3. For more information on this file, see https://docs.djangoproject.com/en/5.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path from decouple import Csv, config from dj_database_url import parse as dburl import os from dotenv import load_dotenv load_dotenv() #API key OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config('DEBUG', default=False, cast=bool) ALLOWED_HOSTS = config('ALLOWED_HOSTS', default=[], cast=Csv()) SITE_DOMAIN = config('SITE_DOMAIN', default='localhost:8000') # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # 3rd apps 'django_extensions', 'widget_tweaks', 'django_seed', 'django_celery_results', # my apps 'backend.accounts.apps.AccountsConfig', 'backend.core.apps.CoreConfig', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'backend.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], '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', ], }, }, ] WSGI_APPLICATION = 'backend.wsgi.application' # Database # https://docs.djangoproject.com/en/5.1/ref/settings/#databases default_dburl = 'sqlite:///' + str(BASE_DIR / 'db.sqlite3') DATABASES = { 'default': config('DATABASE_URL', default=default_dburl, cast=dburl), } # Password validation # https://docs.djangoproject.com/en/5.1/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', }, ] # Internationalization # https://docs.djangoproject.com/en/5.1/topics/i18n/ LANGUAGE_CODE = 'en-us' # 'en-us' TIME_ZONE = 'America/Sao_Paulo' # 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True USE_THOUSAND_SEPARATOR = True DECIMAL_SEPARATOR = ',' #EMAIL SMTP EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_USE_TLS = True EMAIL_HOST_USER = os.getenv("CONF_MAIL") EMAIL_HOST_PASSWORD = os.getenv("CONF_MAIL_PASSWORD") # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/5.1/howto/static-files/ STATIC_URL = '/static/' STATIC_ROOT = BASE_DIR.joinpath('staticfiles') # Default primary key field type # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' LOGIN_URL = '/admin/login/' LOGIN_REDIRECT_URL = 'core:index' # LOGOUT_REDIRECT_URL = 'core:index' # Celery Configuration CELERY_BROKER_URL = 'redis://localhost:6380/0' CELERY_RESULT_BACKEND = 'django-db' # Store task results in the Django database CELERY_ACCEPT_CONTENT = ['json'] CELERY_TASK_SERIALIZER = 'json' CELERY_TIMEZONE = 'UTC' SECURE_SSL_REDIRECT = config('SECURE_SSL_REDIRECT', default=False, cast=bool) SESSION_COOKIE_SECURE = config('SESSION_COOKIE_SECURE', default=False, cast=bool) CSRF_COOKIE_SECURE = config('CSRF_COOKIE_SECURE', default=False, cast=bool) SECURE_HSTS_SECONDS = config('SECURE_HSTS_SECONDS', default=0, cast=int) SECURE_HSTS_INCLUDE_SUBDOMAINS = config('SECURE_HSTS_INCLUDE_SUBDOMAINS', default=False, cast=bool) SECURE_HSTS_PRELOAD = config('SECURE_HSTS_PRELOAD', default=False, cast=bool)