mod: и прод и дев будут работать на SQLite
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -324,8 +324,8 @@ cover/
|
|||||||
# Django stuff:
|
# Django stuff:
|
||||||
*.log
|
*.log
|
||||||
local_settings.py
|
local_settings.py
|
||||||
db.sqlite3
|
*.sqlite3
|
||||||
db.sqlite3-journal
|
*.sqlite3-journal
|
||||||
|
|
||||||
# Flask stuff:
|
# Flask stuff:
|
||||||
instance/
|
instance/
|
||||||
|
|||||||
@@ -67,44 +67,22 @@ WSGI_APPLICATION = 'etpgrf_site.wsgi.application'
|
|||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/6.0/ref/settings/#databases
|
# https://docs.djangoproject.com/en/6.0/ref/settings/#databases
|
||||||
|
|
||||||
if os.getenv('POSTGRES_DB'):
|
DATABASES = {
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.postgresql',
|
|
||||||
'NAME': os.getenv('POSTGRES_DB'),
|
|
||||||
'USER': os.getenv('POSTGRES_USER'),
|
|
||||||
'PASSWORD': os.getenv('POSTGRES_PASSWORD'),
|
|
||||||
'HOST': os.getenv('POSTGRES_HOST'),
|
|
||||||
'PORT': os.getenv('POSTGRES_PORT', '5432'),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
# Если файл `.env` не найден, или не установлены переменные окружения для PostgreSQL
|
|
||||||
print("\033[93mWARNING: Running with SQLite! Check your .env file if you intended to use Postgres.\033[0m")
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': BASE_DIR / 'db.sqlite3',
|
'NAME': BASE_DIR / 'db-etpgrf.sqlite3',
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators
|
||||||
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
{
|
{ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', },
|
||||||
'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', },
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -113,13 +91,11 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
LANGUAGE_CODE = 'ru-RU'
|
LANGUAGE_CODE = 'ru-RU'
|
||||||
TIME_ZONE = 'Europe/Moscow'
|
TIME_ZONE = 'Europe/Moscow'
|
||||||
USE_I18N = True
|
USE_I18N = True
|
||||||
|
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/6.0/howto/static-files/
|
# https://docs.djangoproject.com/en/6.0/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = 'static/'
|
STATIC_URL = 'static/'
|
||||||
|
|
||||||
# Поднимаемся на уровень выше от manage.py, чтобы попасть в корень репозитория
|
# Поднимаемся на уровень выше от manage.py, чтобы попасть в корень репозитория
|
||||||
@@ -129,12 +105,6 @@ STATICFILES_DIRS = [BASE_DIR.parent / 'public' / 'static']
|
|||||||
MEDIA_ROOT = BASE_DIR.parent / 'public' / 'media'
|
MEDIA_ROOT = BASE_DIR.parent / 'public' / 'media'
|
||||||
MEDIA_URL = '/media/'
|
MEDIA_URL = '/media/'
|
||||||
|
|
||||||
# --- ДИАГНОСТИКА ПУТЕЙ ---
|
|
||||||
# print(f"DEBUG: {DEBUG}")
|
|
||||||
# print(f"BASE_DIR: {BASE_DIR}")
|
|
||||||
# print(f"STATIC_ROOT: {STATIC_ROOT}")
|
|
||||||
# -------------------------
|
|
||||||
|
|
||||||
# Default primary key field type
|
# Default primary key field type
|
||||||
# https://docs.djangoproject.com/en/6.0/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/6.0/ref/settings/#default-auto-field
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user