This commit is contained in:
Vinejar
2025-03-30 02:59:20 +03:00
commit 2184ad7171
6 changed files with 231 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
from pymongo import MongoClient
client = MongoClient('mongodb://localhost:27017/')
db = client['Manga'] # Название базы данных
manga_collection = db['Hentai_Manga'] # Название коллекции

View File

@@ -0,0 +1,7 @@
from django.urls import path
from .views import show_manga, show_manga_page
urlpatterns = [
path('manga/<int:manga_id>/', show_manga, name='show_manga'),
path('manga/<int:manga_id>/page/<int:page_number>/', show_manga_page, name='show_manga_page'), # новый маршрут
]

View File

@@ -0,0 +1,19 @@
from django.shortcuts import render
from .models import manga_collection
def show_manga(request, manga_id):
manga = manga_collection.find_one({"id": int(manga_id)}) # Ищем мангу по ID
if not manga:
return render(request, "not_found.html") # Если нет манги, показываем заглушку
return render(request, "manga_view.html", {"manga": manga})
def show_manga_page(request, manga_id, page_number):
manga = manga_collection.find_one({"id": int(manga_id)})
if not manga or page_number < 1 or page_number > manga['len_manga']:
return render(request, "not_found.html")
img_url = manga['imgs_manga'][page_number - 1] # Индекс страницы манги (начинаем с 0)
return render(request, "manga_page.html", {"manga": manga, "img_url": img_url, "page_number": page_number})