fixes
This commit is contained in:
13
dbapp/dbapp/settings/__init__.py
Normal file
13
dbapp/dbapp/settings/__init__.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
|
||||
# Determine the environment and import the appropriate settings
|
||||
ENVIRONMENT = os.getenv('ENVIRONMENT', 'development')
|
||||
|
||||
if ENVIRONMENT == 'production':
|
||||
from .production import *
|
||||
else:
|
||||
from .development import *
|
||||
@@ -12,6 +12,10 @@ https://docs.djangoproject.com/en/5.2/ref/settings/
|
||||
|
||||
from pathlib import Path
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
if os.name == 'nt':
|
||||
OSGEO4W = r"C:\Program Files\OSGeo4W"
|
||||
@@ -29,18 +33,17 @@ 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-7etj5f7buo2a57xv=w3^&llusq8rii7b_gd)9$t_1xcnao!^tq'
|
||||
SECRET_KEY = os.getenv('SECRET_KEY', 'django-insecure-7etj5f7buo2a57xv=w3^&llusq8rii7b_gd)9$t_1xcnao!^tq')
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = os.getenv('DEBUG', 'True').lower() == 'true'
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', 'localhost,127.0.0.1').split(',')
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
# 'django_daisy',
|
||||
'dal',
|
||||
'dal_select2',
|
||||
"admin_interface",
|
||||
@@ -64,6 +67,9 @@ INSTALLED_APPS = [
|
||||
'debug_toolbar'
|
||||
]
|
||||
|
||||
# Note: Custom user model is implemented via OneToOneField relationship
|
||||
# AUTH_USER_MODEL = 'mainapp.CustomUser'
|
||||
|
||||
MIDDLEWARE = [
|
||||
"debug_toolbar.middleware.DebugToolbarMiddleware", #Добавил
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
@@ -81,7 +87,9 @@ ROOT_URLCONF = 'dbapp.urls'
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'DIRS': [
|
||||
BASE_DIR / 'templates', # Main project templates directory
|
||||
],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
@@ -101,12 +109,12 @@ WSGI_APPLICATION = 'dbapp.wsgi.application'
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.contrib.gis.db.backends.postgis',
|
||||
'NAME': 'geodb',
|
||||
'USER': 'geralt',
|
||||
'PASSWORD': '27082025STC',
|
||||
'HOST': 'localhost',
|
||||
'PORT': '5432',
|
||||
'ENGINE': os.getenv('DB_ENGINE', 'django.contrib.gis.db.backends.postgis'),
|
||||
'NAME': os.getenv('DB_NAME', 'db'),
|
||||
'USER': os.getenv('DB_USER', 'user'),
|
||||
'PASSWORD': os.getenv('DB_PASSWORD', 'password'),
|
||||
'HOST': os.getenv('DB_HOST', 'localhost'),
|
||||
'PORT': os.getenv('DB_PORT', '5432'),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +155,7 @@ USE_TZ = True
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATICFILES_DIRS = [
|
||||
os.path.join(BASE_DIR, 'static'),
|
||||
BASE_DIR.parent / 'static', # Reference to the static directory at project root
|
||||
]
|
||||
|
||||
# Default primary key field type
|
||||
9
dbapp/dbapp/settings/development.py
Normal file
9
dbapp/dbapp/settings/development.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from .base import *
|
||||
|
||||
# Development-specific settings
|
||||
DEBUG = True
|
||||
|
||||
# Allow all hosts in development
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
# Additional development settings can go here
|
||||
48
dbapp/dbapp/settings/production.py
Normal file
48
dbapp/dbapp/settings/production.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from .base import *
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Production-specific settings
|
||||
DEBUG = False
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
# In production, specify allowed hosts explicitly
|
||||
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS_PROD', 'localhost,127.0.0.1').split(',')
|
||||
|
||||
# Security settings for production
|
||||
SECURE_BROWSER_XSS_FILTER = True
|
||||
SECURE_CONTENT_TYPE_NOSNIFF = True
|
||||
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
||||
SECURE_HSTS_SECONDS = 31536000
|
||||
SECURE_REDIRECT_EXEMPT = []
|
||||
SECURE_SSL_REDIRECT = True
|
||||
SESSION_COOKIE_SECURE = True
|
||||
CSRF_COOKIE_SECURE = True
|
||||
|
||||
# Template caching for production
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [
|
||||
BASE_DIR / 'templates', # Main project templates directory
|
||||
],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
'loaders': [
|
||||
('django.template.loaders.cached.Loader', [
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
]),
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
# Static files settings for production
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
|
||||
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
|
||||
Reference in New Issue
Block a user