Сменили структуру

This commit is contained in:
zein
2025-11-03 04:09:30 +03:00
parent aa62fd32c2
commit 2d3cfe4736
3 changed files with 13 additions and 21 deletions

View File

@@ -1,16 +1,8 @@
"""
Django settings for DJ_Hentai_manga project.
Generated by 'django-admin startproject' using Django 5.1.7.
For more information on this file, see
https://docs.djangoproject.com/en/5.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.1/ref/settings/
"""
from os import path from os import path
from pathlib import Path from pathlib import Path
import os
from dotenv import load_dotenv
load_dotenv() # загружает .env
# 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

View File

@@ -1,19 +1,19 @@
# db.py
import os import os
from pymongo import MongoClient from pymongo import MongoClient
MONGO_URI = os.getenv('MONGO_URI', 'mongodb://zein:Demius626@mongodb:27017/Server_DB') # Получаем URI только из переменной окружения — НИКАКОГО DEFAULT!
MONGO_URI = os.getenv("MONGO_URI")
if not MONGO_URI:
raise RuntimeError("Ошибка: переменная окружения MONGO_URI не задана!")
# Подключаемся
#Для работы на сервере
client = MongoClient(MONGO_URI) client = MongoClient(MONGO_URI)
#Для локальной разработки # База данных и коллекция берутся из URI!
#client = MongoClient('mongodb://localhost:27017/') # Например: mongodb://.../Manga → база = Manga
db = client.get_database() # ← автоматически из URI
db = client['Manga'] # Название базы данных manga_collection = db["Hentai_Manga"]
manga_collection = db['Hentai_Manga'] # Название коллекции

Binary file not shown.