feat: change view of index to CBV to allow use of templates for HTML use

parent c14d0c68
{% load static %} {% block content %} {% endblock %}
\ No newline at end of file
{% extends "booking/base.html" %}
{% block content %}
<h1> Travel History </h1>
<p>
All Bookings: <br>
{% for booking in bookings_list %}
<ul>
</ul>
{% endfor %}
</p>
{% endblock %}
from django.urls import path
from . import views
from .views import TravelHistoryView
urlpatterns = [
path("", views.index, name="index"),
path("", TravelHistoryView.as_view(), name="index"),
#booking/1
path("<int:Booking_ID>/", views.detail, name="detail"),
......
from django.http import HttpResponse
from django.shortcuts import render, redirect
from .models import Booking
from django.views import View
# Create your views here.
def index(request):
return HttpResponse("booking index")
class TravelHistoryView(View):
def get(self, request):
bookings_list = Booking.objects.order_by("Booking_Date")
context = {
'bookings_list': bookings_list
}
return render(request, 'booking/index.html', context)
def detail(request, Booking_ID):
response = "This is Booking # %s. This will show exact booking details of passenger"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment