diff --git a/.gitignore b/.gitignore index 17d458190..4af19eed2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,29 @@ +# Python +__pycache__/ +*.py[cod] +*.pyo +*.pyd +*.sqlite3 + +# Virtual environment +.venv/ +venv/ +env/ + +# Django +db.sqlite3 +/media/ +staticfiles/ + +# IDE .idea/ .vscode/ -*.iml -.env + +# macOS .DS_Store -venv/ -.pytest_cache/ -**__pycache__/ -*.pyc -app/db.sqlite3 -db.sqlite3 + +# Logs +*.log + +# Environment variables +.env diff --git a/static/css/styles.css b/static/css/styles.css new file mode 100644 index 000000000..e69de29bb diff --git a/taxi/templates/base.html b/taxi/templates/base.html new file mode 100644 index 000000000..76a437067 --- /dev/null +++ b/taxi/templates/base.html @@ -0,0 +1,19 @@ + + + + + {% block title %} + Taxi Service + {% endblock %} + + + +
+ {% block content %}{% endblock %} +
+ + diff --git a/taxi/templates/includes/sidebar.html b/taxi/templates/includes/sidebar.html new file mode 100644 index 000000000..6ec508ead --- /dev/null +++ b/taxi/templates/includes/sidebar.html @@ -0,0 +1,10 @@ + + +{% block sidebar %} + +{% endblock %} diff --git a/taxi/templates/taxi/index.html b/taxi/templates/taxi/index.html new file mode 100644 index 000000000..902e64112 --- /dev/null +++ b/taxi/templates/taxi/index.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} + +{% block content %} +

You have visited the page with information about Taxi Service!

+
The Number of Drivers: {{ num_drivers }}
+
The number of Manufacturers: {{ num_manufacturers }}
+
The Number of Cars: {{ num_cars }}
+{% endblock %} diff --git a/taxi/urls.py b/taxi/urls.py new file mode 100644 index 000000000..31b506fc2 --- /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..aa0451250 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -1,3 +1,17 @@ from django.shortcuts import render +from django.http import HttpRequest, HttpResponse -# 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..000936b08 100644 --- a/taxi_service/settings.py +++ b/taxi_service/settings.py @@ -53,6 +53,8 @@ ROOT_URLCONF = "taxi_service.urls" +APP_DIRS = True + TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", diff --git a/taxi_service/urls.py b/taxi_service/urls.py index 57c939e7f..ca3fbdea6 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", namespace="taxi")), ]