A fun little project where I build a REST API for an F1 database backed by Django.
Some facts:
- The backend is written in Python using the Django framework
- The database is PostgreSQL
- The data is from Ergast, under Creative Commons BY-NC-SA 3.0
- Python 3.9
- PostgreSQL 13 or Docker
- Install Poetry
- Create a virtual environment and activate it
- Run
poetry install
to install all the dependencies - Set up PostgreSQL with e.g.
docker compose up db
- Run
python manage.py migrate
To fill the database with some data, you can use the populate-db.sh
script in the repository.
It is a very basic script that downloads the latest Ergast MySQL database dump and attempts to
convert it such that the rows can be inserted to the PostgreSQL database.
You may need to modify the credentials in the script if you are not using Docker Compose to run the database.
- Run
docker compose build
- Run
docker compose up
The API is now reachable at http://localhost:8000/api/
.
The OpenAPI specification can be downloaded at http://localhost:8000/api/schema/
.
The API documentation can be viewed at http://localhost:8000/api/schema/redoc/
.