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..13125ded2 --- /dev/null +++ b/taxi/urls.py @@ -0,0 +1,9 @@ +from django.urls import path + +from taxi.views import index + +app_name = 'taxi' + +urlpatterns = [ + path("", index, name="index") +] diff --git a/taxi/views.py b/taxi/views.py index 91ea44a21..d1e404c98 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -1,3 +1,18 @@ from django.shortcuts import render -# Create your views here. +from taxi.models import Driver, Manufacturer, Car + + +def index(request): + num_drivers = Driver.objects.all().count() + num_manufacturers = Manufacturer.objects.all().count() + num_cars = Car.objects.all().count() + + return render( + request, + "taxi/index.html", + { + "num_drivers": num_drivers, + "num_manufacturers": num_manufacturers, + "num_cars": num_cars + }) diff --git a/taxi_service/settings.py b/taxi_service/settings.py index 00329f55f..b2ab65ac0 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": [ @@ -123,6 +123,9 @@ # https://docs.djangoproject.com/en/4.0/howto/static-files/ 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..e0890d8d2 100644 --- a/taxi_service/urls.py +++ b/taxi_service/urls.py @@ -1,21 +1,7 @@ -"""taxi_service URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/4.0/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.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..2e7bf9ca0 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,16 @@ +{% load static %} + + +
+ +