diff --git a/.gitignore b/.gitignore index 17d458190..da9822a1e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ venv/ *.pyc app/db.sqlite3 db.sqlite3 +.venv/ \ No newline at end of file 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..3e05c164b --- /dev/null +++ b/taxi/urls.py @@ -0,0 +1,8 @@ +from django.urls import path +from taxi.views import index + +urlpatterns = [ + path("", index, name="index"), +] + +app_name = "taxi" diff --git a/taxi/views.py b/taxi/views.py index 91ea44a21..014b5d031 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -1,3 +1,16 @@ +from django.http import HttpRequest, HttpResponse from django.shortcuts import render -# Create your views here. +from taxi.models import Driver, Manufacturer, Car + + +def index(request: HttpRequest) -> HttpResponse: + 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=context) diff --git a/taxi_service/settings.py b/taxi_service/settings.py index 00329f55f..0d1e4f389 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,11 @@ 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..310fd2815 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", namespace="taxi")), ] diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 000000000..05ebb1416 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,26 @@ + + + + + {% block title %} + Taxi Service + {% endblock %} + {% load static %} + + + +
+
+
+ {% block sidebar %} + {% include "includes/sidebar.html" %} + {% endblock %} +
+
+ {% block content %} + {% endblock %} +
+
+
+ + diff --git a/templates/includes/sidebar.html b/templates/includes/sidebar.html new file mode 100644 index 000000000..dafa33880 --- /dev/null +++ b/templates/includes/sidebar.html @@ -0,0 +1,7 @@ + + diff --git a/templates/taxi/index.html b/templates/taxi/index.html new file mode 100644 index 000000000..7149cd9a9 --- /dev/null +++ b/templates/taxi/index.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{% block title %} + Home page +{% endblock %} + {% block content %} + + {% endblock %} +