In this task, you will start project Taxi service
.
- Create a virtual environment, activate it, and install django via pip:
pip install django
Remember: everything you will do in this project, do with activated virtual environment.
- Start project
taxi_service
inside the current directory (add.
at the end of the command):
django-admin startproject taxi_service .
You should have such structure:
py-taxi-service-startproject
|-> venv
|-> manage.py
|-> README.md
|-> taxi_service
|-> __init__.py
|-> settings.py
...
- Inside
py-taxi-service-startproject
start applicationtaxi
:
python manage.py startapp taxi
- Inside
taxi/models.py
create models according to this diagram:
Note: license_number
and Manufacturer: name
fields should be unique.
-
You have noticed that
Driver
inherits fromAbstractUser
. It means that the standardUser
model should be replaced with the modelDriver
. Notice, thatDriver
has an additional field compared to the standardUser
. -
Edit
admin.py
:- Register all your models in the admin.
- Make Driver's field
license_number
displayed as the other fields. - Add
license_number
to thefieldsets
asAdditional info
category, so you can edit this field while updatingDriver
. - Add
license_number
to theadd_fieldset
asAdditional info
category, so you can fill this field while adding a driver. - Make it possible to search
Car
bymodel
. - Make it possible to filter
Car
bymanufacturer
.
-
Make migrations and migrate.
-
Use
python manage.py test
to run tests. -
Check that each of the html-files has a blank line at the end.
-
Don't forget add
.gitignore
file before pushing. Don't push a lot of extra files(venv
,pycache
,.idea
, etc.).
- Attach screenshots to the comment, NOT in commit.
- It's important to attach images not links to them. See example: