-
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.urlsadd path to thetaxi.urls. Don't forget to specifynamespace. -
Inside
taxi.urlscreate 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.viewscreate functionindex. In this function:- count the number of all drivers with
num_driversvariable - count the number of all manufacturers with
num_manufacturersvariable - count the number of all cars with
num_carsvariable - return
HttpResponsewith rendered template. Pass received data to this template.
- count the number of all drivers with
-
Before you create a template you have to create styles for the template. Create directory
staticnext 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
templatesnext 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
templatescreate templatebase.html, it is a parent template, other templates will extendbase.html. Insidebase.html:- Inside
<head>:- Create block
titlewithTaxi Servicetitle inside - Load static and import
styles.css
- Create block
- Inside
<body>:- Create block
sidebar - Create block
content
- Create block
- Inside
-
Inside
templatescreate a directorytaxi. There you will store templates for the apptaxi. Createindex.htmlthere. Insideindex.html:- Override block
contentand place (as a list) information about:- Number of cars
- Number of drivers
- Number of manufacturers
- Override block
-
Inside
templatescreate a directoryincludes. There you will store includes. Createsidebar.htmlthere. Insidesidebar.html:-
Write realization of
sidebarinclude that must have a list of empty links:- Home page
- Manufacturers
- Cars
- Drivers
-
Anchor tags can serve as placeholder links for this task, meaning the actual destination of the link is not a concern. For example, you can use
href="#"as the link destination. -
In
base.htmlincludesidebar.html, so all these links will be accessible on all pages.
-
-
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 testto check your code results. -
Avoid adding unnecessary files (like
venv,pycache,.idea,db.sqlite3) and remember to include a.gitignorefile in your PR.
- Attach screenshots to the comment, NOT in commit.
- It's important to attach images not links to them. See example:
