Вытащил часть конфига в .env файл

This commit is contained in:
Viner Abubakirov
2026-01-02 20:24:35 +05:00
parent 67a32d8ac7
commit 5f8a0a30b4
4 changed files with 34 additions and 10 deletions

View File

@@ -0,0 +1,10 @@
S3_ACCESS_KEY=""
S3_SECRET_KEY=""
S3_BUCKET_NAME=""
S3_ENDPOINT_URL=""
S3_REGION_NAME=""
S3_SIGNATURE_VERSION=""
DJANGO_DEBUG=False
SECRET_KEY=""
ALLOWED_HOSTS=""

View File

@@ -9,23 +9,25 @@ https://docs.djangoproject.com/en/6.0/topics/settings/
For the full list of settings and their values, see For the full list of settings and their values, see
https://docs.djangoproject.com/en/6.0/ref/settings/ https://docs.djangoproject.com/en/6.0/ref/settings/
""" """
import os
from pathlib import Path from pathlib import Path
from dotenv import load_dotenv
# 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
load_dotenv(BASE_DIR / ".env")
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/6.0/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-=*m3r8o(%h3@7tl2-((k&t%%k)m&*b)i^4w#ixl0i$#6!gtg&+' SECRET_KEY = os.getenv("SECRET_KEY", "")
# 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 = os.getenv("DJANGO_DEBUG", "False") == "True"
ALLOWED_HOSTS = ["*"] ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS", "").split(",")
# Application definition # Application definition
@@ -131,12 +133,12 @@ STORAGES = {
"default": { "default": {
"BACKEND": "storages.backends.s3.S3Storage", "BACKEND": "storages.backends.s3.S3Storage",
"OPTIONS": { "OPTIONS": {
"access_key": "admin", "access_key": os.getenv("S3_ACCESS_KEY", ""),
"secret_key": "admintestpassword", "secret_key": os.getenv("S3_SECRET_KEY", ""),
"bucket_name": "dev-bucket", "bucket_name": os.getenv("S3_BUCKET_NAME", ""),
"endpoint_url": "http://192.168.88.252:9000", "endpoint_url": os.getenv("S3_ENDPOINT_URL", ""),
"region_name": "us-east-1", "region_name": os.getenv("S3_REGION_NAME", ""),
"signature_version": "s3v4", "signature_version": os.getenv("S3_SIGNATURE_VERSION", ""),
} }
}, },

View File

@@ -9,4 +9,5 @@ dependencies = [
"django>=6.0", "django>=6.0",
"django-storages>=1.14.6", "django-storages>=1.14.6",
"pillow>=12.1.0", "pillow>=12.1.0",
"python-dotenv>=1.2.1",
] ]

11
uv.lock generated
View File

@@ -83,6 +83,7 @@ dependencies = [
{ name = "django" }, { name = "django" },
{ name = "django-storages" }, { name = "django-storages" },
{ name = "pillow" }, { name = "pillow" },
{ name = "python-dotenv" },
] ]
[package.metadata] [package.metadata]
@@ -91,6 +92,7 @@ requires-dist = [
{ name = "django", specifier = ">=6.0" }, { name = "django", specifier = ">=6.0" },
{ name = "django-storages", specifier = ">=1.14.6" }, { name = "django-storages", specifier = ">=1.14.6" },
{ name = "pillow", specifier = ">=12.1.0" }, { name = "pillow", specifier = ">=12.1.0" },
{ name = "python-dotenv", specifier = ">=1.2.1" },
] ]
[[package]] [[package]]
@@ -163,6 +165,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892 }, { url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892 },
] ]
[[package]]
name = "python-dotenv"
version = "1.2.1"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/f0/26/19cadc79a718c5edbec86fd4919a6b6d3f681039a2f6d66d14be94e75fb9/python_dotenv-1.2.1.tar.gz", hash = "sha256:42667e897e16ab0d66954af0e60a9caa94f0fd4ecf3aaf6d2d260eec1aa36ad6", size = 44221 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/14/1b/a298b06749107c305e1fe0f814c6c74aea7b2f1e10989cb30f544a1b3253/python_dotenv-1.2.1-py3-none-any.whl", hash = "sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61", size = 21230 },
]
[[package]] [[package]]
name = "s3transfer" name = "s3transfer"
version = "0.16.0" version = "0.16.0"