A REST API for an airport service: airports, routes, airplanes, flights, crews and ticket orders. Built with Django and Django REST Framework.
The code lives on the
developbranch.
Python · Django 5 · Django REST Framework · SimpleJWT · drf-spectacular · SQLite
| Model | Notes |
|---|---|
Airport |
name + closest big city, unique together |
Route |
source → destination airports and distance; rejects a route to itself |
AirplaneType, Airplane |
seat count is derived: rows × seats_in_rows |
Crew |
unique by first + last name |
Flight |
route, airplane, departure/arrival times, crew; rejects an arrival at or before departure |
Order, Ticket |
a ticket is unique per (row, seat, flight) and is checked against the airplane's real seat layout |
Validation sits in the models rather than in the serializers: Route and Flight call full_clean() inside save(), so the rules hold whichever entry point writes the row — API, admin or shell.
Seven resources are registered on a DRF DefaultRouter under /api/:
crews/ · airports/ · routes/ · airplane-types/ · airplanes/ · flights/ · orders/
- Separate serializers per action — list, create and retrieve each get their own, so a list response stays cheap and a detail response stays informative.
- Filtering by query parameters:
?full_name=,?name=,?from=&to=, and date/route filters on flights. - Pagination — page number, 10 per page,
?page_size=up to 1000. select_relatedon routes, so the list view does not walk into an N+1 query.- Throttling — 100 requests/day anonymous, 1000/day authenticated.
- Permissions —
IsAdminOrIfAuthenticatedReadOnly: authenticated users read, staff writes.
JWT (djangorestframework-simplejwt) over a custom user model keyed on email instead of username.
| Endpoint | Purpose |
|---|---|
POST /api/user/create/ |
register |
POST /api/user/token/ |
obtain an access + refresh pair |
POST /api/user/token/refresh/ |
refresh the access token |
POST /api/user/token/verify/ |
verify a token |
GET, PATCH /api/user/me/ |
read or update your own profile |
Send the access token as Authorization: Bearer <token>.
git clone -b develop https://github.com/Zonda001/AirportAPI.git
cd AirportAPI
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.sample .env # then put a real SECRET_KEY in it
python manage.py migrate
python manage.py createsuperuser # create your own admin account
python manage.py runserverWritten as a study project in early 2024 and kept as it was, so that the repository says what it is:
- no test suite
- no Docker or deployment config
drf-spectacularis installed and the views carry@extend_schemaannotations, but no schema endpoint is wired into the URLconf yet- the database is SQLite;
psycopg2sits inrequirements.txtunused