initially make meterplus.ir ready for production

This commit is contained in:
Hadi 2025-10-08 14:04:58 +03:30
parent 672e26c89d
commit bb1b1a8ebf
3 changed files with 55 additions and 23 deletions

View file

@ -11,6 +11,8 @@ https://docs.djangoproject.com/en/5.2/ref/settings/
""" """
import os import os
from pathlib import Path from pathlib import Path
from decouple import config
import dj_database_url
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
@ -20,16 +22,28 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-h!2hx$h=f6ktgdks!g2_*pg_s1nnuyk+j2yd*_x8r+3+3iyfy*' SECRET_KEY = config('DJANGO_SECRET_KEY', default="unsecure-secretkey-kjhsgfjsfgjsfgjsg")
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = config('DEBUG', cast=bool, default=True)
ALLOWED_HOSTS = [] # Allowed hosts
ALLOWED_HOSTS = [host for host in config("DJANGO_ALLOWED_HOSTS", default="").split() if host]
# URL scheme (http or https)
URL_SCHEME = config("URL_SCHEME", default="http")
# CSRF trusted origins (add both with and without port if you use a non-standard port)
CSRF_TRUSTED_ORIGINS = []
for host in ALLOWED_HOSTS:
if host not in ("localhost", "127.0.0.1"):
CSRF_TRUSTED_ORIGINS.append(f"{URL_SCHEME}://{host}")
# Generate base URL for absolute URLs (use first allowed host)
BASE_URL = f"{URL_SCHEME}://{ALLOWED_HOSTS[0]}" if ALLOWED_HOSTS else "http://localhost"
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
# ------ theme ------ # # ------ theme ------ #
'jazzmin', 'jazzmin',
@ -45,6 +59,7 @@ INSTALLED_APPS = [
# ------- third party apps ------- # # ------- third party apps ------- #
'simple_history', 'simple_history',
'django_extensions',
# -------------------------------- # # -------------------------------- #
# ------- my apps ------- # # ------- my apps ------- #
@ -96,13 +111,20 @@ WSGI_APPLICATION = '_base.wsgi.application'
# Database # Database
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases # https://docs.djangoproject.com/en/5.2/ref/settings/#databases
DB_TYPE = config('DB_TYPE', default='sqlite').lower()
if DB_TYPE == 'postgres':
DATABASES = { DATABASES = {
'default': { 'default': dj_database_url.config(default=config('DATABASE_URL'))
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
} }
else:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR/"db.sqlite3",
}
}
# Password validation # Password validation
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
@ -139,15 +161,15 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.2/howto/static-files/ STATIC_URL = '/static/'
STATIC_ROOT = 'ss' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = 'static/'
STATICFILES_DIRS = [ STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static') os.path.join(BASE_DIR, 'static'),
] ]
# Media files
MEDIA_URL = '/media/' MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media' MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field

View file

@ -1,9 +1,14 @@
{ {
"app": "shafafiyat", "app": "meterplus",
"port": 80, "port": 80,
"team-id": "68822f40f04e5bc3027fc2b7", "team-id": "68822f40f04e5bc3027fc2b7",
"build": { "build": {
"location": "iran" "location": "iran"
}, },
"disks": [] "disks": [
{
"name": "media",
"mountTo": "/usr/src/app/media"
}
]
} }

View file

@ -1,10 +1,15 @@
asgiref==3.9.1 asgiref==3.9.1
dj-database-url==3.0.1
Django==5.2.5 Django==5.2.5
django-extensions==4.1
django-jazzmin==3.0.1 django-jazzmin==3.0.1
django-simple-history==3.10.1 django-simple-history==3.10.1
et_xmlfile==2.0.0 et_xmlfile==2.0.0
openpyxl==3.1.5 openpyxl==3.1.5
pillow==11.3.0 pillow==11.3.0
psycopg2==2.9.10
psycopg2-binary==2.9.10
python-decouple==3.8
sqlparse==0.5.3 sqlparse==0.5.3
typing_extensions==4.15.0 typing_extensions==4.15.0
utm==0.8.1 utm==0.8.1