Skip to content

Commit

Permalink
Py taxi service home page (add empty lines)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgubarev88 committed Jul 26, 2023
1 parent 4e41134 commit 698c3a2
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 10 deletions.
9 changes: 9 additions & 0 deletions static/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
body {
margin-top: 10px;
}

.sidebar-nav {
padding: 10px;
list-style: none;
}

1 change: 0 additions & 1 deletion taxi/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from taxi.models import Driver, Manufacturer, Car


# Create your views here.
def index(request):
num_drivers = Driver.objects.count()
num_manufacturers = Manufacturer.objects.count()
Expand Down
4 changes: 2 additions & 2 deletions taxi_service/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Django settings for taxi_service project.
Django's settings for taxi_service project.
Generated by 'django-admin startproject' using Django 4.0.2.
Expand Down Expand Up @@ -56,7 +56,7 @@
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": ["templates"],
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
Expand Down
4 changes: 3 additions & 1 deletion taxi_service/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
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, include


urlpatterns = [
path("admin/", admin.site.urls),
path("", include("taxi.urls", namespace="taxi"))
]
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
18 changes: 14 additions & 4 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,25 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Taxi Service</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">

{% load static %}
<link rel="stylesheet" href="{% static 'css/styles.css' %}">
</head>
<body>
{% block sidebar %}
{% include 'includes/sidebar.html' %}
{% endblock %}
<div class="container-fluid">
<div class="row">
<div class="col-sm-3">
{% block sidebar %}
{% include 'includes/sidebar.html' %}
{% endblock %}

{% block content %}{% endblock %}
</div>
<div class="col-sm-9">
{% block content %}{% endblock %}

</div>
</div>
</div>
</body>
</html>
2 changes: 1 addition & 1 deletion templates/includes/sidebar.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ul>
<ul class="sidebar-nav">
<li><a href="{% url 'taxi:index' %}">Home page</a></li>
<li><a href="#">Manufacturers</a></li>
<li><a href="#">Cars</a></li>
Expand Down
4 changes: 3 additions & 1 deletion templates/taxi/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{% extends 'base.html' %}

{% block content %}
<ul>
<h1 class="p-3 mb-2 bg-primary text-white">Welcome to the Greatest Taxi Service!</h1>
<h3>Our content:</h3>
<ul class="content">
<li>Number of cars: {{ num_cars }}</li>
<li>Number of drivers: {{ num_drivers }}</li>
<li>Number of manufacturers: {{ num_manufacturers }}</li>
Expand Down

0 comments on commit 698c3a2

Please sign in to comment.