Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #886

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
9 changes: 9 additions & 0 deletions static/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
body {
margin-top: 20px;
background: cadetblue;
}

.sidebar-nav {
padding: 0;
list-style: none;
}
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

Choose a reason for hiding this comment

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

There is a syntax error on this line. The import statement should not have a space between path and the newline. It should be from django.urls import path.


from taxi.views import index


app_name = "taxi"
urlpatterns = [
path("", 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.http import HttpRequest, HttpResponse
from django.shortcuts import render
from .models import Driver, Manufacturer, Car

# Create your views here.

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)
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 @@ -122,6 +122,10 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/

STATICFILES_DIRS = [
BASE_DIR / "static",
]

STATIC_URL = "static/"

# Default primary key field type
Expand Down
6 changes: 5 additions & 1 deletion taxi_service/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
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

import taxi

Choose a reason for hiding this comment

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

The import statement import taxi is unnecessary here. Since you are already including the taxi app's URLs with include('taxi.urls', namespace='taxi'), you can safely remove this import.



urlpatterns = [
path("admin/", admin.site.urls),
path("", include("taxi.urls", namespace="taxi"))
]
29 changes: 29 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
{% block title %}
<title>Taxi Service</title>
{% endblock %}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
{% load static %}
<link rel="stylesheet" href="{% static 'css/styles.css' %}">
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-sm-3">
{% block sidebar %}
{% include "includes/sidebar.html" %}
{% endblock %}
</div>
<div class="col-sm-9">
{% block content %}
{% endblock %}
</div>
</div>
</div>
</body>
</html>
14 changes: 14 additions & 0 deletions templates/includes/sidebar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<ul class="sidebar-nav">
<li>
<a href="{% url "taxi:index" %}" style="color: #f5dd5d">Home page</a>
</li>
<li>
<a href="#" style="color: #f5dd5d">Manufacturers</a>
</li>
<li>
<a href="#" style="color: #f5dd5d">Cars</a>
</li>
<li>
<a href="#" style="color: #f5dd5d">Drivers</a>
Comment on lines +6 to +12

Choose a reason for hiding this comment

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

The links for 'Manufacturers', 'Cars', and 'Drivers' are currently placeholders (href="#"). If there are specific views or URLs for these sections, consider updating these links to use the {% url %} template tag to point to the correct paths.

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

{% block content %}
<h1>Taxi HomePage</h1>
<p>Welcome To Our Teleport-Taxi</p>
<h1>Our Service is:</h1>
<ul>
<li>Drivers: {{ num_drivers }}</li>
<li>Manufacturers: {{ num_manufacturers }}</li>
<li>Cars: {{ num_cars }}</li>
</ul>
{% endblock %}
Loading