Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added static/css/styles.css
Empty file.
9 changes: 9 additions & 0 deletions taxi/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.urls import path

from taxi.views import index

urlpatterns = [
path("", index, name="index")
]

app_name = "taxi"
16 changes: 15 additions & 1 deletion taxi/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
from django.shortcuts import render
from django.http import HttpResponse, HttpRequest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates the checklist requirement to group and separate imports: "Add a blank line between different groups of imports and ensure appropriate ordering of imports." Ensure imports are ordered (standard library, third-party, local) and put a blank line between the third-party (django) imports and local taxi imports.


# Create your views here.
from taxi.models import Car, Driver, Manufacturer


def index(requests: HttpRequest) -> HttpResponse:
num_drivers = Driver.objects.count()
num_manufacturers = Manufacturer.objects.count()
num_cars = Car.objects.count()

return render(
requests, "taxi/index.html",
{"num_drivers": num_drivers,
"num_manufacturers": num_manufacturers,
"num_cars": num_cars}
)
10 changes: 3 additions & 7 deletions taxi_service/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/

Expand All @@ -28,7 +27,6 @@

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
Expand Down Expand Up @@ -56,7 +54,7 @@
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
Expand All @@ -71,7 +69,6 @@

WSGI_APPLICATION = "taxi_service.wsgi.application"


# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases

Expand All @@ -82,7 +79,6 @@
}
}


# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators

Expand Down Expand Up @@ -118,11 +114,11 @@

USE_TZ = True


# 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
Expand Down
3 changes: 2 additions & 1 deletion taxi_service/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
]
23 changes: 23 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
{% load static %}
<link rel="stylesheet" href="{% static 'css/styles.css' %}">
<title>{% block title %}Taxi Service{%endblock%}</title>
<meta>
</head>
<body>

<div id="sidebar">
{% block sidebar %}
{% include 'includes/sidebar.html' %}
{% endblock %}
</div>

<div id="content">
{% block content %}
{% endblock %}
</div>
</body>
</html>
6 changes: 6 additions & 0 deletions templates/includes/sidebar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ul>
<li><a href="{% url 'taxi:index' %}">Home Page</a></li>
<li><a href="#">Manufacturers</a></li>
<li><a href="#">Cars</a></li>
<li><a href="#">Drivers</a></li>
</ul>
11 changes: 11 additions & 0 deletions templates/taxi/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends 'base.html' %}

{% block title %}Home page{% endblock %}

{% block content %}
<ul>
<li>{{num_cars}}</li>
<li>{{num_drivers}}</li>
<li>{{num_manufacturers}}</li>
</ul>
{% endblock %}