Skip to content

Instantly share code, notes, and snippets.

@sunmeat
Created March 3, 2026 10:47
Show Gist options
  • Select an option

  • Save sunmeat/ad6bacb2a566d414771cbefd06257187 to your computer and use it in GitHub Desktop.

Select an option

Save sunmeat/ad6bacb2a566d414771cbefd06257187 to your computer and use it in GitHub Desktop.
часткові хтмл-сторінки (інклюдимо картку філії)
views.py:
from django.shortcuts import render, reverse
class Branch:
def __init__(self, city, role, services, url_name, detail_text):
self.city = city
self.role = role
self.services = services
self.detail_url = reverse(url_name)
self.detail_text = detail_text
def branches_list(request):
branches = [
Branch(
city="Одеса, Україна",
role="Головний офіс та логістичний хаб",
services=[
"Приймання та відправка вантажів по всій Україні",
"Митне оформлення експорт",
"Консолідація дрібних вантажів",
"Склад тимчасового зберігання",
],
url_name="odesa",
detail_text="Детальніше про філію в Одесі"
),
Branch(
city="Орлеан, Франція",
role="Представництво в ЄС",
services=[
"Митне оформлення імпорт до ЄС",
"Доставка по всій Франції та країнах ЄС",
"Розконсолідація та адресна доставка",
"Супровід зворотних вантажів",
],
url_name="orleans",
detail_text="Детальніше про філію в Орлеані"
),
]
context = {
'title': 'Філії',
'branches': branches,
}
return render(request, 'branches_list.html', context)
def odesa(request):
return render(request, 'odesa.html', {'title': 'Філія в Одесі'})
def orleans(request):
return render(request, 'orleans.html', {'title': 'Філія в Орлеані'})
===============================================================================================================
company_site / templates / branches_list.html:
{% extends 'base.html' %}
{% block title %}Філії Versailles Cortège{% endblock %}
{% block content %}
<main class="main-branches">
<section class="branches-hero">
<div class="container">
<h1 class="page-title">Наші філії</h1>
<p class="page-subtitle">Два ключові офіси для контролю вантажів на обох кінцях маршруту</p>
</div>
</section>
<section class="branches-list">
<div class="container">
<div class="branches-grid">
{% for branch in branches %}
{% include 'components/branch_card.html' with branch=branch %}
{% endfor %}
</div>
</div>
</section>
</main>
{% endblock %}
===============================================================================================================
company_site / templates / components / branch_card.html (часткова сторінка, папку та файл треба створити):
<div class="branch-card">
<h2 class="branch-city">{{ branch.city }}</h2>
<p class="branch-role">{{ branch.role }}</p>
<ul>
{% for service in branch.services %}
<li>{{ service }}</li>
{% endfor %}
</ul>
<a href="{{ branch.detail_url }}" class="btn btn-outline">
{{ branch.detail_text }}
</a>
</div>
===============================================================================================================
ПРАКТИКА: спробуйте додати на вью ще декілька об'єктів у список :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment