сделал нав панель

This commit is contained in:
Андрей Дувакин 2024-04-16 21:38:53 +05:00
parent 5223346e3f
commit 3c7086feae
15 changed files with 140 additions and 18 deletions

View File

@ -109,6 +109,10 @@ USE_TZ = True
STATIC_URL = 'static/'
STATICFILES_DIRS = [
BASE_DIR / 'static',
]
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
MEDIA_URL = "/media/"

View File

@ -1,22 +1,16 @@
"""
URL configuration for CineSync project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path
from django.urls import include, path
urlpatterns = [
path('', include('home.urls')),
path('admin/', admin.site.urls),
]
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
if settings.DEBUG:
import debug_toolbar
urlpatterns += [path('__debug__/', include(debug_toolbar.urls))]

9
CineSync/home/urls.py Normal file
View File

@ -0,0 +1,9 @@
from django.urls import path
from home.views import homepage
app_name = 'home'
urlpatterns = [
path('', homepage, name='homepage'),
]

View File

@ -1,3 +1,12 @@
from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def homepage(request):
template = render(
request,
'home/homepage.html'
)
return HttpResponse(
template,
)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

View File

@ -0,0 +1,26 @@
.header_icon {
width: 5vw;
border-radius: 1.5vw;
padding:1vw;
}
.header_row, .auth_row, header {
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: nowrap;
}
header {
justify-content: space-between;
background-color: #ffffff;
position: fixed;
margin: 1%;
width: 98%;
border-radius: 0.8vw;;
}
.header_container {
width: 100%;
}
.nav-item {
margin: 5px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,19 @@
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{% block title %}{% endblock title %}</title>
<link href="{% static 'css/bootstrap/bootstrap.min.css' %}" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/header.css' %}"/>
<link rel="stylesheet" href="{% static 'css/footer.css' %}"/>
</head>
<body>
{% include 'includes/header.html' %}
<main>
{% block content %} Контент не подвезлм :( {% endblock content %}
</main>
{% include 'includes/footer.html' %}
<script defer src="{% static 'js/bootstrap/bootstrap.min.js' %}"></script>
</body>
</html>

View File

@ -0,0 +1,8 @@
{% extends "base.html" %}
{% load static %}
{% block title %}
Главная
{% endblock title %}
{% block content %}
{% endblock %}

View File

View File

@ -0,0 +1,38 @@
{% load static %}
<div class="header_container">
<header>
<div class="header_row">
<img src="{% static 'img/logo.jpg' %}" class="header_icon col-4">
<ul class="nav nav-pills">
{% with request.resolver_match.view_name as view_name %}
<li class="nav-item">
<a class="nav-link {% if view_name == 'home:homepage' %} active {% endif %}"
href="{% url 'home:homepage' %}">Главная</a>
</li>
<li class="nav-item">
<a class="nav-link {% if view_name == 'home:homepage' %} active {% endif %}"
href="{% url 'home:homepage' %}">Фильмы</a>
</li>
<li class="nav-item">
<a class="nav-link {% if view_name == 'home:homepage' %} active {% endif %}"
href="{% url 'home:homepage' %}">Расписание</a>
</li>
{% endwith %}
</ul>
</div>
<div class="auth_row">
{% if user.is_authenticated %}
{% else %}
<ul class="nav nav-pills">
<li class="nav-item">
<a class="btn btn-primary" href="{% url 'home:homepage' %}">Регистрация</a>
</li>
<li class="nav-item">
<a class="btn btn-secondary" href="{% url 'home:homepage' %}">Вход</a>
</li>
</ul>
{% endif %}
</div>
</header>
</div>