Перешел на структуру шаблонов
All checks were successful
Auto-Deploy-Shop / deploy (push) Successful in 7s
All checks were successful
Auto-Deploy-Shop / deploy (push) Successful in 7s
This commit is contained in:
6
.continueignore
Normal file
6
.continueignore
Normal file
@@ -0,0 +1,6 @@
|
||||
venv/
|
||||
.venv/
|
||||
__pycache__/
|
||||
.git/
|
||||
*.pyc
|
||||
node_modules/
|
||||
@@ -55,7 +55,9 @@ ROOT_URLCONF = 'core.urls'
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'DIRS': [
|
||||
os.path.join(BASE_DIR, 'templates'),
|
||||
],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
|
||||
@@ -18,9 +18,12 @@ from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from django.conf.urls.static import static # <--- Добавьте эту строку
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('home/', views.home, name='home'),
|
||||
path('about/', views.about, name='about'),
|
||||
path('', include('products.urls')), # Главная страница теперь ведет в products
|
||||
]
|
||||
|
||||
|
||||
8
core/views.py
Normal file
8
core/views.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# core/views.py
|
||||
from django.shortcuts import render
|
||||
|
||||
def home(request):
|
||||
return render(request, 'home.html')
|
||||
|
||||
def about(request):
|
||||
return render(request, 'about.html')
|
||||
44
products/templates/products/list copy.html
Normal file
44
products/templates/products/list copy.html
Normal file
@@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Мой Магазин</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; margin: 40px; }
|
||||
.product { border-bottom: 1px solid #ccc; padding: 10px; margin-bottom: 10px; }
|
||||
.admin-link { background: #417690; color: white; padding: 10px; text-decoration: none; border-radius: 4px; }
|
||||
img { max-width: 200px; height: auto; display: block; margin-top: 10px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="background: #28a745; color: white; text-align: center; padding: 20px; font-family: sans-serif; border-bottom: 4px solid #1e7e34;">
|
||||
<h1 style="margin: 0;">🚀 Система автоматизирована!</h1>
|
||||
<p style="margin: 5px 0 0;">Этот билд был собран и развернут автоматически через Gitea Actions.</p>
|
||||
<small>Время деплоя: 21.01.2026</small>
|
||||
|
||||
<!-- 🔥 Вот здесь вывод переменной окружения -->
|
||||
<p style="margin-top: 15px; font-size: 14px;">
|
||||
<strong>ENV_TYPE:</strong> {{ env_type }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<h1>Список товаров</h1>
|
||||
<a href="/admin/" class="admin-link">Перейти в панельку админа</a>
|
||||
<hr>
|
||||
|
||||
{% for product in products %}
|
||||
<div class="product">
|
||||
<h2>{{ product.name }}</h2>
|
||||
<p>{{ product.description }}</p>
|
||||
<p><strong>Цена: {{ product.price }} руб.</strong></p>
|
||||
{% if product.image %}
|
||||
<img src="{{ product.image.url }}" alt="{{ product.name }}">
|
||||
{% else %}
|
||||
<p>Нет изображения</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% empty %}
|
||||
<p>Товаров пока нет.</p>
|
||||
{% endfor %}
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,44 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Мой Магазин</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; margin: 40px; }
|
||||
.product { border-bottom: 1px solid #ccc; padding: 10px; margin-bottom: 10px; }
|
||||
.admin-link { background: #417690; color: white; padding: 10px; text-decoration: none; border-radius: 4px; }
|
||||
img { max-width: 200px; height: auto; display: block; margin-top: 10px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="background: #28a745; color: white; text-align: center; padding: 20px; font-family: sans-serif; border-bottom: 4px solid #1e7e34;">
|
||||
<h1 style="margin: 0;">🚀 Система автоматизирована!</h1>
|
||||
<p style="margin: 5px 0 0;">Этот билд был собран и развернут автоматически через Gitea Actions.</p>
|
||||
<small>Время деплоя: 21.01.2026</small>
|
||||
<!-- templates/products/list.html -->
|
||||
{% extends 'base.html' %}
|
||||
|
||||
<!-- 🔥 Вот здесь вывод переменной окружения -->
|
||||
<p style="margin-top: 15px; font-size: 14px;">
|
||||
<strong>ENV_TYPE:</strong> {{ env_type }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<h1>Список товаров</h1>
|
||||
<a href="/admin/" class="admin-link">Перейти в панельку админа</a>
|
||||
<hr>
|
||||
{% block title %}Список продуктов{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>Список продуктов</h1>
|
||||
<div class="row">
|
||||
{% for product in products %}
|
||||
<div class="product">
|
||||
<h2>{{ product.name }}</h2>
|
||||
<p>{{ product.description }}</p>
|
||||
<p><strong>Цена: {{ product.price }} руб.</strong></p>
|
||||
{% if product.image %}
|
||||
<img src="{{ product.image.url }}" alt="{{ product.name }}">
|
||||
{% else %}
|
||||
<p>Нет изображения</p>
|
||||
{% endif %}
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ product.name }}</h5>
|
||||
<p class="card-text">{{ product.description }}</p>
|
||||
<p class="card-text"><strong>Цена: {{ product.price }} руб.</strong></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% empty %}
|
||||
<p>Товаров пока нет.</p>
|
||||
<div class="col-12">
|
||||
<p>Продуктов пока нет.</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</body>
|
||||
</html>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -1,6 +1,7 @@
|
||||
from django.urls import path
|
||||
from .views import product_list
|
||||
|
||||
app_name = 'products' # Это нужно добавить для регистрации пространства имён
|
||||
urlpatterns = [
|
||||
path('', product_list, name='product_list'),
|
||||
path('', product_list, name='list'),
|
||||
]
|
||||
13
templates/about.html
Normal file
13
templates/about.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!-- templates/about.html -->
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}О нас{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>О нас</h1>
|
||||
<p>Это описание нашего проекта.</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
28
templates/base.html
Normal file
28
templates/base.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<!-- templates/base.html -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{% block title %}Мой проект{% endblock %}</title>
|
||||
<!-- Bootstrap CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
{% block extra_css %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<!-- Навигационная панель -->
|
||||
{% include 'components/navbar.html' %}
|
||||
|
||||
<!-- Основной контент -->
|
||||
<main class="container mt-4">
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<!-- Футер -->
|
||||
{% include 'components/footer.html' %}
|
||||
|
||||
<!-- Bootstrap JS -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
{% block extra_js %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
6
templates/components/footer.html
Normal file
6
templates/components/footer.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<!-- templates/components/footer.html -->
|
||||
<footer class="bg-dark text-white text-center py-4 mt-5">
|
||||
<div class="container">
|
||||
<p>© 2023 Мой проект. Все права защищены.</p>
|
||||
</div>
|
||||
</footer>
|
||||
30
templates/components/navbar.html
Normal file
30
templates/components/navbar.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<!-- templates/components/navbar.html -->
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="{% url 'home' %}">Мой проект</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav me-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'home' %}">Главная</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'products:list' %}">Продукты</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="navbar-nav">
|
||||
{% if user.is_authenticated %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Выход</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Вход</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
17
templates/home.html
Normal file
17
templates/home.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!-- templates/home.html -->
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}Главная страница{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="jumbotron">
|
||||
<h1 class="display-4">Добро пожаловать!</h1>
|
||||
<p class="lead">Это главная страница нашего проекта.</p>
|
||||
<hr class="my-4">
|
||||
<p>Здесь можно разместить основную информацию о проекте.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user