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
34 changes: 26 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Empty file added static/css/styles.css
Empty file.
19 changes: 19 additions & 0 deletions taxi/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="styles.css">

Choose a reason for hiding this comment

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

The requirement to "Load static and import styles.css" means you should use Django's template system for static files. This involves two steps:

  1. Add {% load static %} at the very top of this file.
  2. Update the href attribute to use the static tag, like this: href="{% static 'css/styles.css' %}".

Hardcoding the URL like this prevents Django from finding the file correctly.

{% block title %}
<title>Taxi Service</title>
{% endblock %}
</head>
<body>
<div id="sidebar">
{% block sidebar %}
{% include "includes/sidebar.html" %}
{% endblock %}
</div>
<div id="content">
{% block content %}{% endblock %}
</div>
</body>
</html>
10 changes: 10 additions & 0 deletions taxi/templates/includes/sidebar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@


{% block sidebar %}
<ul>
<li><a href="#">Home page</a></li>
<li><a href="#">Manufacturer</a></li>

Choose a reason for hiding this comment

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

Good job creating the list of links! Just a small correction: the task requires the link text to be "Manufacturers" (plural).

<li><a href="#">Cars</a></li>
<li><a href="#">Drivers</a></li>
</ul>
{% endblock %}
Comment on lines +3 to +10

Choose a reason for hiding this comment

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

The {% block sidebar %} tags are not needed in an included template. The {% include %} tag simply inserts the content of this file, so you only need the <ul> list here.

Choose a reason for hiding this comment

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

This violates a requirement to have each HTML file end with a blank line. Please add a newline character after this line.

8 changes: 8 additions & 0 deletions taxi/templates/taxi/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "base.html" %}

{% block content %}
<h1>You have visited the page with information about Taxi Service!</h1>
<h6>The Number of Drivers: {{ num_drivers }}</h6>
<h6>The number of Manufacturers: {{ num_manufacturers }}</h6>
<h6>The Number of Cars: {{ num_cars }}</h6>
Comment on lines +5 to +7

Choose a reason for hiding this comment

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

According to the task description, this information should be placed 'as a list'. Using multiple <h6> tags is not semantically correct for a list of items. Please use a <ul> with <li> elements for each piece of information.

{% endblock %}
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"

Choose a reason for hiding this comment

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

This violates checklist item #1: 'Ensure each file ends with a single blank line.' Please add a newline character at the end of the file.

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 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)
2 changes: 2 additions & 0 deletions taxi_service/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@

ROOT_URLCONF = "taxi_service.urls"

APP_DIRS = True

TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
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", namespace="taxi")),
]