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..f0934e996 --- /dev/null +++ b/taxi/urls.py @@ -0,0 +1,10 @@ +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..7c5dabb62 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -1,3 +1,13 @@ from django.shortcuts import render -# Create your views here. +from taxi.models import Driver, Manufacturer, Car + + +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..2413ccf7d --- /dev/null +++ b/templates/base.html @@ -0,0 +1,30 @@ +{% load static %} + + + + + + + + {% block title %} + Taxi Service + {% endblock %} + + + + +
+ {% 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..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..e70196fb6 --- /dev/null +++ b/templates/taxi/index.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} + +{% block content %} + +{% endblock %}