initially make meterplus.ir ready for production
This commit is contained in:
		
							parent
							
								
									672e26c89d
								
							
						
					
					
						commit
						bb1b1a8ebf
					
				
					 3 changed files with 55 additions and 23 deletions
				
			
		| 
						 | 
				
			
			@ -11,6 +11,8 @@ https://docs.djangoproject.com/en/5.2/ref/settings/
 | 
			
		|||
"""
 | 
			
		||||
import os
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
from decouple import config
 | 
			
		||||
import dj_database_url
 | 
			
		||||
 | 
			
		||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
 | 
			
		||||
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/
 | 
			
		||||
 | 
			
		||||
# 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!
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
INSTALLED_APPS = [
 | 
			
		||||
    # ------ theme ------ #
 | 
			
		||||
    'jazzmin',
 | 
			
		||||
| 
						 | 
				
			
			@ -45,6 +59,7 @@ INSTALLED_APPS = [
 | 
			
		|||
 | 
			
		||||
    # ------- third party apps ------- #
 | 
			
		||||
    'simple_history',
 | 
			
		||||
    'django_extensions',
 | 
			
		||||
    # -------------------------------- #
 | 
			
		||||
 | 
			
		||||
    # ------- my apps ------- #
 | 
			
		||||
| 
						 | 
				
			
			@ -96,13 +111,20 @@ WSGI_APPLICATION = '_base.wsgi.application'
 | 
			
		|||
# Database
 | 
			
		||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
 | 
			
		||||
 | 
			
		||||
DATABASES = {
 | 
			
		||||
    'default': {
 | 
			
		||||
        'ENGINE': 'django.db.backends.sqlite3',
 | 
			
		||||
        'NAME': BASE_DIR / 'db.sqlite3',
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
DB_TYPE = config('DB_TYPE', default='sqlite').lower()
 | 
			
		||||
 | 
			
		||||
if DB_TYPE == 'postgres':
 | 
			
		||||
    DATABASES = {
 | 
			
		||||
        'default': dj_database_url.config(default=config('DATABASE_URL'))
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
else:
 | 
			
		||||
    DATABASES = {
 | 
			
		||||
        "default": {
 | 
			
		||||
            "ENGINE": "django.db.backends.sqlite3",
 | 
			
		||||
            "NAME": BASE_DIR/"db.sqlite3",
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
# Password validation
 | 
			
		||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
 | 
			
		||||
| 
						 | 
				
			
			@ -139,15 +161,15 @@ USE_TZ = True
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
# Static files (CSS, JavaScript, Images)
 | 
			
		||||
# https://docs.djangoproject.com/en/5.2/howto/static-files/
 | 
			
		||||
STATIC_ROOT = 'ss'
 | 
			
		||||
STATIC_URL = 'static/'
 | 
			
		||||
STATIC_URL = '/static/'
 | 
			
		||||
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
 | 
			
		||||
STATICFILES_DIRS = [
 | 
			
		||||
    os.path.join(BASE_DIR, 'static')
 | 
			
		||||
    os.path.join(BASE_DIR, 'static'),
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
# Media files
 | 
			
		||||
MEDIA_URL = '/media/'
 | 
			
		||||
MEDIA_ROOT = BASE_DIR / 'media'
 | 
			
		||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
 | 
			
		||||
 | 
			
		||||
# Default primary key field type
 | 
			
		||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										21
									
								
								liara.json
									
										
									
									
									
								
							
							
						
						
									
										21
									
								
								liara.json
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,9 +1,14 @@
 | 
			
		|||
{
 | 
			
		||||
    "app": "shafafiyat",
 | 
			
		||||
    "port": 80,
 | 
			
		||||
    "team-id": "68822f40f04e5bc3027fc2b7",
 | 
			
		||||
    "build": {
 | 
			
		||||
        "location": "iran"
 | 
			
		||||
    },
 | 
			
		||||
    "disks": []
 | 
			
		||||
}
 | 
			
		||||
  "app": "meterplus",
 | 
			
		||||
  "port": 80,
 | 
			
		||||
  "team-id": "68822f40f04e5bc3027fc2b7",
 | 
			
		||||
  "build": {
 | 
			
		||||
    "location": "iran"
 | 
			
		||||
  },
 | 
			
		||||
  "disks": [
 | 
			
		||||
    {
 | 
			
		||||
      "name": "media",
 | 
			
		||||
      "mountTo": "/usr/src/app/media"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,15 @@
 | 
			
		|||
asgiref==3.9.1
 | 
			
		||||
dj-database-url==3.0.1
 | 
			
		||||
Django==5.2.5
 | 
			
		||||
django-extensions==4.1
 | 
			
		||||
django-jazzmin==3.0.1
 | 
			
		||||
django-simple-history==3.10.1
 | 
			
		||||
et_xmlfile==2.0.0
 | 
			
		||||
openpyxl==3.1.5
 | 
			
		||||
pillow==11.3.0
 | 
			
		||||
psycopg2==2.9.10
 | 
			
		||||
psycopg2-binary==2.9.10
 | 
			
		||||
python-decouple==3.8
 | 
			
		||||
sqlparse==0.5.3
 | 
			
		||||
typing_extensions==4.15.0
 | 
			
		||||
utm==0.8.1
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue