From bdfcee770e3a52eae277e807d953e93378f92202 Mon Sep 17 00:00:00 2001 From: TomekSzatal Date: Mon, 16 Mar 2026 12:34:12 +0100 Subject: [PATCH 1/3] Taxi service home page --- static/css/styles.css | 0 taxi/urls.py | 8 ++++++++ taxi/views.py | 15 ++++++++++++++- taxi_service/settings.py | 6 +++++- taxi_service/urls.py | 3 ++- templates/base.html | 25 +++++++++++++++++++++++++ templates/includes/sidebar.html | 6 ++++++ templates/taxi/index.html | 13 +++++++++++++ 8 files changed, 73 insertions(+), 3 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..e69de29bb diff --git a/taxi/urls.py b/taxi/urls.py new file mode 100644 index 000000000..e94ecc323 --- /dev/null +++ b/taxi/urls.py @@ -0,0 +1,8 @@ +from django.urls import path +from . import views + +app_name = "taxi" + +urlpatterns = [ + path("", views.index, name="index"), +] \ No newline at end of file diff --git a/taxi/views.py b/taxi/views.py index 91ea44a21..ccc5e50a8 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -1,3 +1,16 @@ from django.shortcuts import render +from taxi.models import Driver, Manufacturer, Car -# Create your views here. + +def index(request): + num_drivers = Driver.objects.count() + num_manufacturers = Manufacturer.objects.count() + num_cars = Car.objects.count() + + context = { + "num_drivers": num_drivers, + "num_manufacturers": num_manufacturers, + "num_cars": num_cars, + } + + return render(request, "taxi/index.html", context) \ No newline at end of file diff --git a/taxi_service/settings.py b/taxi_service/settings.py index 00329f55f..f0f5220b5 100644 --- a/taxi_service/settings.py +++ b/taxi_service/settings.py @@ -56,7 +56,7 @@ TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [], + "DIRS": [BASE_DIR / "templates"], "APP_DIRS": True, "OPTIONS": { "context_processors": [ @@ -124,6 +124,10 @@ 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..f025b6903 100644 --- a/taxi_service/urls.py +++ b/taxi_service/urls.py @@ -14,8 +14,9 @@ 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..ba07c7624 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,25 @@ +{% load static %} + + + + + {% block title %}Taxi Service{% endblock %} + + + + + + + + +
+ {% block content %} + {% endblock %} +
+ + + diff --git a/templates/includes/sidebar.html b/templates/includes/sidebar.html new file mode 100644 index 000000000..b0fe9d3a2 --- /dev/null +++ b/templates/includes/sidebar.html @@ -0,0 +1,6 @@ + diff --git a/templates/taxi/index.html b/templates/taxi/index.html new file mode 100644 index 000000000..d9592e02c --- /dev/null +++ b/templates/taxi/index.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} + +{% block content %} + +

Taxi Service

+ + + +{% endblock %} From 5bc21eb38d7381799b23ad567536233003c5cc41 Mon Sep 17 00:00:00 2001 From: TomekSzatal Date: Mon, 16 Mar 2026 12:35:59 +0100 Subject: [PATCH 2/3] add newline --- taxi/urls.py | 2 +- taxi/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/taxi/urls.py b/taxi/urls.py index e94ecc323..bf73e46f0 100644 --- a/taxi/urls.py +++ b/taxi/urls.py @@ -5,4 +5,4 @@ urlpatterns = [ path("", views.index, name="index"), -] \ No newline at end of file +] diff --git a/taxi/views.py b/taxi/views.py index ccc5e50a8..83a491d1c 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -13,4 +13,4 @@ def index(request): "num_cars": num_cars, } - return render(request, "taxi/index.html", context) \ No newline at end of file + return render(request, "taxi/index.html", context) From cb864a7600c2a3731acf118250bcdf524cc6b557 Mon Sep 17 00:00:00 2001 From: TomekSzatal Date: Mon, 16 Mar 2026 14:11:14 +0100 Subject: [PATCH 3/3] add newline --- taxi/urls.py | 1 + 1 file changed, 1 insertion(+) diff --git a/taxi/urls.py b/taxi/urls.py index bf73e46f0..77f188dea 100644 --- a/taxi/urls.py +++ b/taxi/urls.py @@ -1,4 +1,5 @@ from django.urls import path + from . import views app_name = "taxi"