Skip to main content

A Django Rest API for fetching and creating trips and their schedules.

Project description

Django Trips API

This is a Django Rest API for fetching and creating trips and schedules.

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',
]

Add the following to your root urls.py file.

urlpatterns = [
    ...
    url(r'^trips/', include('django_trips.urls'))
]

Note that the URL path can be whatever you want.

API

The following pages are served in the development:

Page Method URL
Trips List GET http://localhost:8000/api/trips/
Search Trip GET http://localhost:8000/api/trips?name=Islamabad/
Single Trip GET http://localhost:8000/api/trip/trip-id-or-slug/
Update Trip PUT http://localhost:8000/api/trip/trip-id-or-slug/
Update Trip PATCH http://localhost:8000/api/trip/trip-id-or-slug/
Delete Trip DELETE http://localhost:8000/api/trip/trip-id-or-slug/

API permissions

Authentication
SessionAuthentication
BasicAuthentication
Permissions
IsAuthenticated

Trip List

http://localhost:8000/api/trips/

This endpoint is used to list all the trips Using the GET request type.

Search Trip

http://localhost:8000/api/trip/id-or-slug

Search specific trips. Here are the params that can be passed while searching. You can also mix the params together to narrow down the search.

param description example
name Search Trips that contains specific name. /api/trips/?name=Islamabad
price Find trips that contains price greater than or equal /api/trips/?price=200
duration Find trips of duration (days) greater than or equal /api/trips/?duration=2
from_date Find trips that are scheduled greater than or specified date /api/trips/?from_date=2020-01-02
to_date Find trips that are scheduled less than or equal to specified date /api/trips/?to_date=2020-01-02

Single Trip

http://localhost:8000/api/trip/id-or-slug

This endpoint is used to fetch a single trip using GET request type.

Update Trip (using PUT)

http://localhost:8000/api/trip/trip-id-or-slug/

This endpoint is used to update a single trip using PUT request type. You would need to pass the complete trip object.

reset_of_params = {}
data = {
    'age_limit': 39,
    **reset_of_params,
}

Update Trip (using PATCH)

http://localhost:8000/api/trip/trip-id-or-slug/

data = {
    'age_limit': 39,
}

Update Trip (using PUT)

http://localhost:8000/api/trip/trip-id-or-slug/

This endpoint is used to delete a single trip using DELETE request type.

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 run
> 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

Docker Commands

Action Command
Run Server make run
Trail Logs make logs
Attach sever make attach
Stop server make stop
* Destroy docker container. make destory

* caution, this will remove all your data.

How to Contribute

Contributions are welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-trips-0.2.6.3.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_trips-0.2.6.3-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file django-trips-0.2.6.3.tar.gz.

File metadata

  • Download URL: django-trips-0.2.6.3.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6

File hashes

Hashes for django-trips-0.2.6.3.tar.gz
Algorithm Hash digest
SHA256 953e88197c965d4adfd597dfedcf1f6eec81f2934ca2a44e2e465968135c08d9
MD5 fc325be9f8886c712e27714fb1717845
BLAKE2b-256 1eb9ff7eade84f8a1e4ae0b7a5cc460b1b6c999cbd3f876dbf8da9d237c164a5

See more details on using hashes here.

File details

Details for the file django_trips-0.2.6.3-py3-none-any.whl.

File metadata

  • Download URL: django_trips-0.2.6.3-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6

File hashes

Hashes for django_trips-0.2.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c6060ed766deae84126e44b2fadcf32880d35f98e1944fbc7bedb5a9d7337e27
MD5 3b7a6687a6c62b624c7426b7239883fd
BLAKE2b-256 2011536f1b0c4aba7c07626f868e91a98e3d0408b296967891f722b983893aef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page