Skip to content
Open

S #1341

Show file tree
Hide file tree
Changes from 2 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.
8 changes: 8 additions & 0 deletions taxi/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.urls import path
from .views import index

Choose a reason for hiding this comment

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

This import statement violates a couple of code style rules from the checklist:

  1. Checklist item Solution #3: You should use an absolute import, like from taxi.views import index, instead of a relative import.
  2. Checklist item Black, readme fixed #2: There should be a blank line between the third-party Django import on line 1 and this local application import.

Choose a reason for hiding this comment

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

This import is still relative. As mentioned in the previous review, please change this to an absolute import to comply with checklist item #3. It should be from taxi.views import index.


app_name = 'taxi'

urlpatterns = [
path("", index, name="index")
]
17 changes: 16 additions & 1 deletion taxi/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
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.' Please add a blank line before this line to separate the local application import from the third-party Django import.



def index(request):
num_drivers = Driver.objects.all().count()
num_manufacturers = Manufacturer.objects.all().count()
num_cars = Car.objects.all().count()

return render(
request,
"taxi/index.html",
{
"num_drivers": num_drivers,
"num_manufacturers": num_manufacturers,
"num_cars": num_cars
})
5 changes: 4 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 @@ -123,6 +123,9 @@
# 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
Expand Down
18 changes: 2 additions & 16 deletions taxi_service/urls.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
"""taxi_service URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
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

urlpatterns = [
path("admin/", admin.site.urls),
path("", include("taxi.urls", namespace="taxi"))
]
16 changes: 16 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{% block title %}Taxi Service{% endblock title %}</title>

<link rel="stylesheet" href="{% static 'css/styles.css' %}">
</head>
<body>
{% block sidebar %}
{% include "includes/sidebar.html" %}
{% endblock sidebar %}
{% block content %}{% endblock content %}
</body>
</html>
19 changes: 19 additions & 0 deletions templates/includes/sidebar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<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>





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 remove the extra blank lines, leaving only one at the end of the file.

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 remove the extra blank lines at the end of this file.

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

{% block content %}
<ul>
<li>Number of cars {{ num_cars }}</li>
<li>Number of drivers {{ num_drivers }}</li>
<li>Number of manufacturers {{ num_manufacturers }}</li>
</ul>

{% endblock content %}

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 single blank line after {% endblock content %} to meet the project's code style requirements.

Loading