Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions static/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
margin: 10px;
}
10 changes: 10 additions & 0 deletions taxi/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.urls import path

from taxi.views import index


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

app_name = "taxi"
12 changes: 11 additions & 1 deletion taxi/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
from django.shortcuts import render

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

Choose a reason for hiding this comment

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

This violates checklist item #2: "Add a blank line between different groups of imports and ensure appropriate ordering of imports." Add a blank line between the third-party import (from django.shortcuts import render) and the local import (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)
11 changes: 8 additions & 3 deletions taxi_service/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion taxi_service/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
]
30 changes: 30 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% load static %}
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"
integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
{% block title %}
<title>Taxi Service</title>
{% endblock %}
<link rel="stylesheet" href="{% static "css/styles.css" %}">
</head>

<body>
<div>
{% block sidebar %}
{% include "includes/sidebar.html" %}
{% endblock %}
</div>

<div>
{% 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="#">Home page</a></li>

Choose a reason for hiding this comment

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

This violates checklist item #2: "Add a blank line between different groups of imports and ensure appropriate ordering of imports." Add a blank line between the third-party import (from django.shortcuts import render) and the local import (from taxi.models import Driver, Manufacturer, Car).

<li><a href="#">Manufacturers</a></li>
<li><a href="#">Cars</a></li>
<li><a href="#">Drivers</a></li>
</ul>
9 changes: 9 additions & 0 deletions templates/taxi/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends "base.html" %}

{% block content %}
<ul>
<li>Cars: {{ num_cars }}</li>
<li>Drivers: {{ num_drivers }}</li>
<li>Manufacturers: {{ num_manufacturers }}</li>
</ul>
{% endblock %}