Skip to main content

Django Trips API

This is a Django REST API for managing and retrieving trips, schedules, bookings, and related travel data.

This service is a core component of the DestinationPak project — a platform designed to make exploring and booking adventures across Pakistan easier and more accessible.

Installation

Simply do:

pip install django-trips

Usage

Add the app into your installed apps in your project's settings file.

INSTALLED_APPS = [
    ...
    'django_trips',
]

Migrate

python manage.py migrate 

Add the following to your root urls.py or to your desired file location.

urlpatterns = [
    ...
    path('trips/', include(('django_trips.api.urls', 'trips-api'), namespace='trips-api')),
]

You can replace trips/ to any namespace you like for the api.

Generate random trips.

Before you generate random scripts, make sure you have the required settings available in your project. If you want to use the default settings set USE_DEFAULT_TRIPS=True. The script depends upon these variables, if you don't want to use the default settings set the following settings.

  1. TRIP_DESTINATIONS
  2. TRIP_DEPARTURE_LOCATION
  3. TRIP_LOCATIONS = TRIP_DEPARTURE_LOCATION + TRIP_DESTINATIONS
  4. TRIP_LOCATIONS_BY_REGION (optional) - maps each location name above to its PROVINCE-level parent, e.g. {"Gilgit-Baltistan": ("Hunza", "Skardu")}, so Location.region resolves instead of staying None.
  5. TRIP_HOSTS
  6. TRIP_FACILITIES
  7. TRIP_CATEGORIES
  8. TRIP_GEARS
python manage.py generate_trips --batch_size=100

Change the batch_size variable to create as much of trips you want.

Developer Docs & API Documentation

You can access the all available API endpoints on the following links.

  • http://localhost:8000/api/v1/schema/redoc
  • http://localhost:8000/api/v1/schema/swagger-ui/

API Endpoints

The following pages are served in the development:

Page Method URL
All Trips List GET http://localhost:8000/api/v1/trips/
Upcoming Trips List GET http://localhost:8000/api/v1/trips/upcoming/
Search Trip GET http://localhost:8000/api/v1/trips/upcoming/?name=Boston
Single Trip GET http://localhost:8000/api/v1/trips/{identifier}/
Update Trip PUT http://localhost:8000/api/v1/trips/{identifier}/
Delete Trip DELETE http://localhost:8000/api/v1/trips/{identifier}/
Create Trip POST http://localhost:8000/api/v1/trips/
Toggle Trip Wishlist POST http://localhost:8000/api/v1/trips/{identifier}/wishlist/
Destinations List GET http://localhost:8000/api/v1/destinations/
Destinations Detail GET TODO
All Trip Bookings GET http://localhost:8000/api/v1/trips/{trip_id}/bookings/
Book a Trip POST http://localhost:8000/api/v1/trips/{trip_id}/bookings/create/
Booking Details GET http://localhost:8000/api/v1/trips/bookings/{number}/
Update Booking PUT http://localhost:8000/api/v1/trips/bookings/{number}/
Cancel Booking POST http://localhost:8000/api/v1/trips/bookings/{number}/cancel/
Review Trip GET TODO
Trip Reviews & Comments GET TODO

Filtering & ordering

GET /trips/ supports the following query parameters (see TripFilter in api/filters.py):

Param Description
name Case-insensitive partial match on trip name
destination Comma-separated destination slugs, e.g. ?destination=hunza,skardu
category Comma-separated category slugs, e.g. ?category=hiking,camping
duration_from / duration_to Trip duration in days (inclusive)
price_from / price_to Only matches trips with a single published schedule in this price range
date_from / date_to Only matches trips with a single published schedule in this date range (YYYY-MM-DD)
ordering One of name, duration, price; prefix with - for descending, e.g. ?ordering=-price

GET /trips/upcoming/ supports its own equivalent set of filters (name, price_from/price_to, date_from/date_to, destination, duration_from/duration_to) plus ?ordering= on trip__name, price, start_date, or trip__duration.

API permissions

Authentication Token Life
SessionAuthentication UNLIMITED
JWTAuthentication 7 Days
Permissions
IsAuthenticated
IsAdminUser

Develop Django Trips

Kick the docker build using the following command.

make build

This task may take few minutes.

Once the build has been completed, spin up the docker and migrate the database.

> make dev.up
> make shell 
> make update_db

Create a superuser with username admin.

> make shell
> python manage.py createsuperuser

Create batch of trips. Run the following command inside docker shell.

> python manage.py  generate_trips --batch_size=100
OR
> make random_trips

Test

Run tests using the following command.

make test

Docker Commands

Action Command
Run Server make dev.up
Trail Logs make logs
Attach sever make attach
Stop server make stop
* Destroy docker container. make destroy

* caution, this will remove all your data.

How to Contribute

Contributions are welcome! Whether it's bug fixes, new features, improving documentation, or sharing feedback — we'd love your help.

Please fork the repository, make your changes in a feature branch, and submit a pull request. For major changes, consider opening an issue first to discuss what you’d like to work on.


Thank you for being a part of the Django Trips journey.
Together, we can make travel management smarter, faster, and more delightful.

Reach out in you need further assistance. admin@destinationpak.com

Happy coding! ✨

Release files for django-trips 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-trips 1.1.0
File Size Uploaded
django_trips-1.1.0.tar.gz 21.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-trips 1.1.0
File Interpreter ABI Platform
django_trips-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 40.8 kB

Release files / django_trips-1.1.0.tar.gz

Download URL django_trips-1.1.0.tar.gz
Size 21.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9a9f6abd2dac0ef52a0c977c9bd5732ef8d75a6e7db1a268593544a3a7e5a635
BLAKE2b-256 checksum
How to use checksums
7a86e2aa5c890bdb4cbd37415e21b750c25e4a9d6736795a0274b5b69d49c330
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 26, 2026.

Transparency log

Release files / django_trips-1.1.0-py3-none-any.whl

Download URL django_trips-1.1.0-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ef082527da32077609d619ae71dca856b9b075f0b8894888cd4c8ba30922e7e
BLAKE2b-256 checksum
How to use checksums
e916f0c8abd33ed3c2038d0df4a7943d7ede10d1a6ae7134272d62d6cc7220ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 26, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page