Files
api-bashgah/config/settings/base.py
T
2026-06-20 20:45:34 +03:30

202 lines
5.2 KiB
Python

"""
Django settings for bashgah project.
Generated by 'django-admin startproject' using Django 5.0.3.
For more information on this file, see
https://docs.djangoproject.com/en/5.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.0/ref/settings/
"""
import os
from pathlib import Path
from datetime import timedelta
# 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.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-3sf^ag=#a2jfpv!*6v4=6suvdcn50e$o%+v6-46y)ck-*lfpu5'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
OTP_BYPASS = False
ALLOWED_HOSTS = ['*']
CORS_ALLOWED_ORIGINS = [
"http://localhost:3000",
"http://localhost:3001",
"https://bashgah.liara.run",
"https://lgg-bashgah.liara.run",
"https://bashgah.loolegostar.com",
"https://mojrian.loolegostar.com",
"https://admin-mojrian.loolegostar.com",
"https://admin-mojrian.liara.run",
"https://apibashgah.loolegostar.com",
"https://mojrian.loolegostar.com",
"https://ad-mojrian.loolegostar.com",
"https://r4hdyt6dbhg07agq1w2plrv3.37.255.224.143.sslip.io",
"http://r4hdyt6dbhg07agq1w2plrv3.37.255.224.143.sslip.io",
]
CSRF_TRUSTED_ORIGINS = CORS_ALLOWED_ORIGINS
AUTH_USER_MODEL = 'cuser.CUser'
# Application definition
LOCAL_APPS = [
'apps.cuser',
'apps.product',
'apps.appsetting',
'apps.userprofile',
'apps.dgcode',
'apps.order',
'apps.project',
'apps.user_auth',
'apps.emtiyazat',
'apps.projectcode',
]
THIRD_PARTY_APPS = [
'rest_framework',
'drf_spectacular',
'django_filters',
'corsheaders',
'debug_toolbar',
'import_export',
]
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
*THIRD_PARTY_APPS,
*LOCAL_APPS,
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
]
ROOT_URLCONF = 'config.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / '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',
],
},
},
]
WSGI_APPLICATION = 'config.wsgi.application'
SIMPLE_JWT = {
"ACCESS_TOKEN_LIFETIME": timedelta(minutes=30),
"REFRESH_TOKEN_LIFETIME": timedelta(days=30),
}
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
'rest_framework.authentication.SessionAuthentication',
)
}
# Database !
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'bashgah-dev2',
'USER': 'postgres',
'PASSWORD': '335577!@',
'HOST': '127.0.0.1',
'PORT': '5432'
}
}
# Password validation
# https://docs.djangoproject.com/en/5.0/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.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/
STATIC_URL = 'static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
CELERY_BROKER_URL = "redis://default:qmmVDw1ui6O6nNrCqI3ATnGJxFeR3xpsdy972ENmOCUi1YfgaHpV2oJrWxLccxRU@heu1dmurfwhighrpg7v773yw:6379/0"
CELERY_TASK_RESULT_EXPIRES = 86400
#CELERY_RESULT_BACKEND = "redis://heu1dmurfwhighrpg7v773yw:6379"
CELERY_BROKER_CONNECTION_RETRY_ON_STARTUP = True
CELERY_TIMEZONE = 'Asia/Tehran'