Skip to content
Open

Develop #1363

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
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 . import views

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...'. A blank line should be added before this line to separate third-party imports (like Django) from local application imports.

Choose a reason for hiding this comment

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

This violates checklist item #3: 'Use absolute imports instead of relative imports'. Please change this relative import to an absolute import, such as from taxi import views.


app_name = "taxi"

urlpatterns = [
path("", views.index, name="index"),
]
15 changes: 14 additions & 1 deletion taxi/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
from django.shortcuts import render
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...'. According to the code style guidelines, you should separate third-party imports (like django) from local application imports (like taxi) with a blank line.


# 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)
6 changes: 5 additions & 1 deletion taxi_service/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
Expand Down Expand Up @@ -124,6 +124,10 @@

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", "taxi"), namespace="taxi")),
]
25 changes: 25 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% load static %}

<!DOCTYPE html>
<html>
<head>
<title>{% block title %}Taxi Service{% endblock %}</title>

<link rel="stylesheet" href="{% static 'css/styles.css' %}">
</head>

<body>

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

<div class="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="#">Home page</a></li>
<li><a href="#">Manufacturers</a></li>
<li><a href="#">Cars</a></li>
<li><a href="#">Drivers</a></li>
</ul>
13 changes: 13 additions & 0 deletions templates/taxi/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "base.html" %}

{% block content %}

<h1>Taxi Service</h1>

<ul>
<li>Number of cars: {{ num_cars }}</li>
<li>Number of drivers: {{ num_drivers }}</li>
<li>Number of manufacturers: {{ num_manufacturers }}</li>
</ul>

{% endblock %}
Loading