From bc3115200d3df087570cce68e1b86e7fbd77e840 Mon Sep 17 00:00:00 2001 From: Lukian Date: Thu, 19 Feb 2026 16:46:12 +0000 Subject: [PATCH 1/4] done task --- static/css/styles.css | 3 +++ taxi/urls.py | 9 +++++++++ taxi/views.py | 11 ++++++++++- taxi_service/settings.py | 11 ++++++++--- taxi_service/urls.py | 4 +++- templates/base.html | 30 ++++++++++++++++++++++++++++++ templates/includes/sidebar.html | 12 ++++++++++++ templates/taxi/index.html | 8 ++++++++ 8 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 static/css/styles.css create mode 100644 taxi/urls.py create mode 100644 templates/base.html create mode 100644 templates/includes/sidebar.html create mode 100644 templates/taxi/index.html diff --git a/static/css/styles.css b/static/css/styles.css new file mode 100644 index 000000000..5a5827350 --- /dev/null +++ b/static/css/styles.css @@ -0,0 +1,3 @@ +body { + margin: 10px; +} diff --git a/taxi/urls.py b/taxi/urls.py new file mode 100644 index 000000000..c84d41686 --- /dev/null +++ b/taxi/urls.py @@ -0,0 +1,9 @@ +from django.urls import path +from taxi.views import index + + +urlpatterns = [ + path("", index, name="index"), +] + +app_name = "taxi" \ No newline at end of file diff --git a/taxi/views.py b/taxi/views.py index 91ea44a21..6076b8601 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -1,3 +1,12 @@ from django.shortcuts import render +from .models import Driver, Manufacturer, Car -# Create your views here. + +def index(request): + context = { + "num_drivers": Driver.objects.count(), + "num_manufacturers": Manufacturer.objects.count(), + "num_cars": Car.objects.count(), + } + + return render(request, "taxi/index.html", context) diff --git a/taxi_service/settings.py b/taxi_service/settings.py index 00329f55f..28e904bdb 100644 --- a/taxi_service/settings.py +++ b/taxi_service/settings.py @@ -9,7 +9,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.0/ref/settings/ """ - +import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -56,7 +56,7 @@ TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [], + "DIRS": [os.path.join(BASE_DIR, "templates")], "APP_DIRS": True, "OPTIONS": { "context_processors": [ @@ -122,7 +122,12 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.0/howto/static-files/ -STATIC_URL = "static/" +STATIC_URL = "/static/" + +STATICFILES_DIRS = [ + BASE_DIR / "static", +] + # Default primary key field type # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field diff --git a/taxi_service/urls.py b/taxi_service/urls.py index 57c939e7f..b199b11c1 100644 --- a/taxi_service/urls.py +++ b/taxi_service/urls.py @@ -14,8 +14,10 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path, include + urlpatterns = [ path("admin/", admin.site.urls), + path("", include(("taxi.urls", "taxi"), namespace="taxi")), ] diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 000000000..0447a9047 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,30 @@ +{% load static %} {# !!!important!!! #} + + + + + + + + {% block title %} + Taxi Service + {% endblock %} + + + + +
+ {% block sidebar %} + {% include "includes/sidebar.html" %} + {% endblock %} +
> + +
+ {% block content %} + {% endblock %} +
+ + + \ No newline at end of file diff --git a/templates/includes/sidebar.html b/templates/includes/sidebar.html new file mode 100644 index 000000000..a286ec31c --- /dev/null +++ b/templates/includes/sidebar.html @@ -0,0 +1,12 @@ + + Home page + + + Manufacturers + + + Cars + + + Drivers + diff --git a/templates/taxi/index.html b/templates/taxi/index.html new file mode 100644 index 000000000..2553637d8 --- /dev/null +++ b/templates/taxi/index.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} + +{% block content %} + {{ num_car }} + {{ num_drivers }} + {{ num_manufacturer }} +{% endblock %} + From d1573032c3738cf2a10b7fd300d96421f3eb4c59 Mon Sep 17 00:00:00 2001 From: Lukian Date: Thu, 19 Feb 2026 16:48:20 +0000 Subject: [PATCH 2/4] done task --- taxi/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taxi/urls.py b/taxi/urls.py index c84d41686..22d115a44 100644 --- a/taxi/urls.py +++ b/taxi/urls.py @@ -6,4 +6,4 @@ path("", index, name="index"), ] -app_name = "taxi" \ No newline at end of file +app_name = "taxi" From c0413ff00b95f00aefd4db0083cc30bdf95d2356 Mon Sep 17 00:00:00 2001 From: Lukian Date: Thu, 19 Feb 2026 22:32:11 +0000 Subject: [PATCH 3/4] fixed --- taxi/urls.py | 1 + taxi/views.py | 2 +- templates/base.html | 4 ++-- templates/includes/sidebar.html | 18 ++++++------------ templates/taxi/index.html | 9 +++++---- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/taxi/urls.py b/taxi/urls.py index 22d115a44..f0934e996 100644 --- a/taxi/urls.py +++ b/taxi/urls.py @@ -1,4 +1,5 @@ from django.urls import path + from taxi.views import index diff --git a/taxi/views.py b/taxi/views.py index 6076b8601..c525610f2 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -1,5 +1,5 @@ from django.shortcuts import render -from .models import Driver, Manufacturer, Car +from taxi.models import Driver, Manufacturer, Car def index(request): diff --git a/templates/base.html b/templates/base.html index 0447a9047..0cc1bffdc 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,4 +1,4 @@ -{% load static %} {# !!!important!!! #} +{% load static %} @@ -27,4 +27,4 @@ - \ No newline at end of file + diff --git a/templates/includes/sidebar.html b/templates/includes/sidebar.html index a286ec31c..b0fe9d3a2 100644 --- a/templates/includes/sidebar.html +++ b/templates/includes/sidebar.html @@ -1,12 +1,6 @@ - - Home page - - - Manufacturers - - - Cars - - - Drivers - + diff --git a/templates/taxi/index.html b/templates/taxi/index.html index 2553637d8..e70196fb6 100644 --- a/templates/taxi/index.html +++ b/templates/taxi/index.html @@ -1,8 +1,9 @@ {% extends "base.html" %} {% block content %} - {{ num_car }} - {{ num_drivers }} - {{ num_manufacturer }} +
    +
  • Cars: {{ num_cars }}
  • +
  • Drivers: {{ num_drivers }}
  • +
  • Manufacturers: {{ num_manufacturers }}
  • +
{% endblock %} - From 7c28317f61c3620af1413ae9c8dcfbadf57fba19 Mon Sep 17 00:00:00 2001 From: Lukian Date: Thu, 19 Feb 2026 23:08:32 +0000 Subject: [PATCH 4/4] fixed --- taxi/views.py | 1 + templates/base.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/taxi/views.py b/taxi/views.py index c525610f2..7c5dabb62 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -1,4 +1,5 @@ from django.shortcuts import render + from taxi.models import Driver, Manufacturer, Car diff --git a/templates/base.html b/templates/base.html index 0cc1bffdc..2413ccf7d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -19,7 +19,7 @@ {% block sidebar %} {% include "includes/sidebar.html" %} {% endblock %} -> +
{% block content %}