Package: django-trips
Django Trips APIThis is a Django Rest API for fetching and creating trips and schedules.InstallationSimply do:pipinstalldjango-tripsUsageAdd the app into your installed apps in your project's settings file.INSTALLED_APPS = [
    ...
    'django_trips',
]Migratepython manage.py migrateAdd the following to your rooturls.pyor to your desired file location.urlpatterns = [
    ...
    path('trips/', include(('django_trips.api.urls', 'trips-api'), namespace='trips-api')),
]You can replacetrips/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 setUSE_DEFAULT_TRIPS=True.
The script depends upon these variables, if you don't want to use the default settings set the
following settings.TRIP_DESTINATIONSTRIP_DEPARTURE_LOCATIONTRIP_LOCATIONS = TRIP_DEPARTURE_LOCATION + TRIP_DESTINATIONSTRIP_HOSTSTRIP_FACILITIESTRIP_CATEGORIESTRIP_GEARSpython manage.py generate_trips --batch_size=100Change thebatch_sizevariable to create as much of trips you want.API EndpointsThe following pages are served in the development:PageMethodURLScheduled Trips ListGEThttp://localhost:8000/api/trips/Available Trips ListGEThttp://localhost:8000/api/trips/by/availability/Search TripGEThttp://localhost:8000/api/trips?name=Boston/Single TripGEThttp://localhost:8000/api/trip/trip-id-or-slug/Update TripPUThttp://localhost:8000/api/trip/trip-id-or-slug/Update TripPATCHhttp://localhost:8000/api/trip/trip-id-or-slug/Delete TripDELETEhttp://localhost:8000/api/trip/trip-id-or-slug/DestinationGEThttp://localhost:8000/api/destinations/Destination DetailGEThttp://localhost:8000/api/destination/location-slugAll Trip BookingsGEThttp://localhost:8000/api/trip/bookingsSingle BookingsGEThttp://localhost:8000/api/trip/booking/idSingle Trip BookingsGEThttp://localhost:8000/api/trip//bookingsAPI permissionsAuthenticationSessionAuthenticationBasicAuthenticationPermissionsIsAuthenticatedTrip Listhttp://localhost:8000/api/trips/This endpoint is used to list all the trips by schedule using theGETrequest type. These trips have specified
(fixed) schedule. These trips use django modelTripSchedulefor creating their schedule. Once the schedule is expired,
these trips do not renew automatically.
These are the trip with "static" schedule data.Trip List by Availabilityhttp://localhost:8000/api/trips/by/availability/There is another mechanism which would like you to define dynamic trips schedule. Which is usingTripAvailabilitymodel. In this model you can define the recurrence of any trip, weekly, daily, or monthly and these trip may
auto-renew themselves. They come handy when you have dynamic trips schedule.Search Triphttp://localhost:8000/api/trip/id-or-slug?destination=<destination name, destination name 2,>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.paramdescriptionexamplename (str)Find trips that contains specific name./api/trips/?name=Bostondestination[]Filter trips with specific destinations.destination=Boston,Londonprice_from (str)Find trips that has price greater than or equal to the given amount/api/trips/?price_from=200price_to (str)Find trips that has price less than or equal to the given amount/api/trips/?price_to=200duration_from (int)Find trips having duration greater than or equal to the given number/api/trips/?duration_from=2duration_to (int)Find trips having duration less  than or equal to the given number/api/trips/?duration_to=10date_from (date)Find trips that are scheduled greater than or specified date<yyyy-mm-dd>/api/trips/?date_from=2020-01-02date_to (date)Find trips that are scheduled less than or equal to specified date<yyyy-mm-dd>/api/trips/?date_from=2020-01-02Single Triphttp://localhost:8000/api/trip/id-or-slugThis 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.Get Destinations Listhttp://localhost:8000/api/destinations/This endpoint is used to fetch all destinations available.Get Destination Detailhttp://localhost:8000/api/destination/destination-slugGiven a slug, this endpoint provides detail about a single trip.Create Trip bookinghttp://localhost:8000/api/trip/bookingsGET:Get all the trips list using theGETrequest method.POST:Create trip booking by giving the following "example" data in thePOSTrequest.{
    "name": "tom latham",
    "trip": "5-days-trip-to-city-center",
    "phone_number": "tom",
    "cnic_number": "1234234-23423",
    "email": "a@gmail.com",
    "target_date": "2021-09-01",
    "message": "Tom booking# 1"
}Single Trip booking Operationshttp://localhost:8000/api/trip/booking/<booking-id>/Retrieve, Update & Delete a single trip booking.All Trip Bookingshttp://localhost:8000/api/trip/<trip-slug>bookings/Retrieve all bookings of a single trip.Develop Django TripsKick the docker build using the following command.make buildThis task may take few minutes.Once the build has been completed, spin up the docker and migrate the database.>makerun
>makeshell>makeupdate_dbCreate a superuser with usernameadmin.>makeshell
>pythonmanage.pycreatesuperuserCreate batch of trips. Run the following command inside docker shell.>pythonmanage.pygenerate_trips--batch_size=100OR
>makerandom_tripsTestRun tests using the following command.make testsDocker CommandsActionCommandRun Servermake runTrail Logsmake logsAttach severmake attachStop servermake stop* Destroy docker container.make destory* caution, this will remove all your data.How to ContributeContributions are welcome!