diff --git a/.gitignore b/.gitignore index 17d458190..c0851f69b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ .idea/ .vscode/ -*.iml +.iml .env .DS_Store -venv/ +.venv/ .pytest_cache/ -**__pycache__/ +__pycache__/ *.pyc app/db.sqlite3 db.sqlite3 diff --git a/static/__init__.py b/static/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/static/css/__init__.py b/static/css/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/static/css/styles.css b/static/css/styles.css new file mode 100644 index 000000000..26e33776b --- /dev/null +++ b/static/css/styles.css @@ -0,0 +1,6 @@ +body { + font-family: Arial, sans-serif; + background-color: #f0f0f0; + margin: 0; + padding: 0; +} \ No newline at end of file diff --git a/taxi/urls.py b/taxi/urls.py new file mode 100644 index 000000000..bd33074c8 --- /dev/null +++ b/taxi/urls.py @@ -0,0 +1,10 @@ +from django.urls import path +from django.conf import settings +from django.conf.urls.static import static +from . import views + +app_name = "taxi" + +urlpatterns = [ + path("", views.index, name="index"), +] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/taxi/views.py b/taxi/views.py index 91ea44a21..7552f867b 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -1,3 +1,15 @@ from django.shortcuts import render +from .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) diff --git a/taxi_service/settings.py b/taxi_service/settings.py index 00329f55f..42a0a736c 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,7 @@ # 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..097c9f9a7 100644 --- a/taxi_service/urls.py +++ b/taxi_service/urls.py @@ -13,9 +13,10 @@ 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 +from taxi import views urlpatterns = [ - path("admin/", admin.site.urls), + path("", views.index, name="home"), + path("taxi/", include("taxi.urls", namespace="taxi")), ] diff --git a/templates/__init__.py b/templates/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 000000000..b76995315 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,25 @@ + + + + {% block title %} + Example Title + {% endblock %} + + + + + {% load static %} + + + + + +
+ {% block content %}{% endblock %} +
+ + diff --git a/templates/includes/__init__.py b/templates/includes/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/templates/includes/sidebar.html b/templates/includes/sidebar.html new file mode 100644 index 000000000..ea54ade03 --- /dev/null +++ b/templates/includes/sidebar.html @@ -0,0 +1,6 @@ + diff --git a/templates/taxi/__init__.py b/templates/taxi/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/templates/taxi/index.html b/templates/taxi/index.html new file mode 100644 index 000000000..156ac384c --- /dev/null +++ b/templates/taxi/index.html @@ -0,0 +1,18 @@ + + + + + Home page + + + {% block content %} +

Home page

+

Statistics

+ + {% endblock %} + +