-
Read the guideline before start
-
Use the following command to load prepared data from fixture to test and debug your code:
python manage.py loaddata taxi_service_db_data.json
.
Feel free to add more data using admin panel, if needed.
In this task, you should implement the home page of the site.
- Inside
taxi_service.urls
add path to thetaxi.urls
. Don't forget to specifynamespace
. - Inside
taxi.urls
create a path for the home page. This page should open when you are accessinghttp://127.0.0.1:8000/
. Give this path the nameindex
. - Inside
taxi.views
create functionindex
. In this function:- count the number of all drivers with
num_drivers
variable - count the number of all manufacturers with
num_manufacturers
variable - count the number of all cars with
num_cars
variable - return
HttpResponse
with rendered template. Pass received data to this template (don't importHttpResponse
if you userender
, this import is unnecessary).
- count the number of all drivers with
- Before you create a template you have to create styles for the
template. Create directory
static
next to the directorytaxi
. Inside this directory create a file with the following pathcss/styles.css
. Don't forget to do all necessary steps so that Django can serve these static files. - Create directory
templates
next to the directorytaxi
. There you will store templates for pages. Edit settings so that engine knows where to look for template source files. - Inside directory
templates
create templatebase.html
, it is a parent template, other templates will extendbase.html
. Insidebase.html
:- Inside
<head>
:- Create block
title
withTaxi Service
title inside - Load static and import
styles.css
- Create block
- Inside
<body>
:- Create block
sidebar
- Create block
content
- Create block
- Inside
- Inside
templates
create a directorytaxi
. There you will store templates for the apptaxi
. Createindex.html
there. Insideindex.html
:- Override block
content
and place (as a list) information about:- Number of cars
- Number of drivers
- Number of manufacturers
- Override block
- Inside
templates
create a directoryincludes
. There you will store includes. Createsidebar.html
there. Insidesidebar.html
:- Write realization of
sidebar
include that must have a list of empty links:- Home page
- Manufacturers
- Cars
- Drivers
- In
base.html
includesidebar.html
, so all these links will be accessible on all pages.
- Write realization of
- Check that you put empty lines at the end of each HTML file.
- Run server, open
http://127.0.0.1:8000/
, check if the information is there and if it is correct. - Run
python manage.py test
to check your code results. - Don't push a lot of extra files(
venv
,pycache
,.idea
, etc.) and don't forget to add.gitignore
to your PR.
- Attach screenshots to the comment, NOT in commit.
- It's important to attach images not links to them. See example: