My form:
class TestCaseUpdateForm(forms.ModelForm):
class Meta:
model = TestCase
fields = ( 'name', 'executable', 'parameter_list', 'executable_type', 'test_type' , 'project_name', 'created_by')
My views:
class EditCaseView(UpdateView):
model = TestCase
form_class = TestCaseUpdateForm
template_name_suffix = '_update_form'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
pk = self.kwargs.get(self.pk_url_kwarg)
queryset = self.get_queryset().filter(pk=pk)
case = queryset.get()
context['my_case'] = case
context['my_exetype'] = TestCase.EXECUTABLE_TYPE_CHOICES
context['my_ttype'] = TestCase.TEST_TYPE_CHOICES
context['projnames'] = PROJNAME_CHOICES
return context
def get_success_url(self):
print("get_success_url")
return reverse("integratedTest:testCase")
My model:
PROJNAME_CHOICES = (
('Name1', 'Name1'),
('Name2','Name2'),
('Name3','Name3')
)
class TestCase(models.Model):
EXECUTABLE_TYPE_CHOICES = (
('e_type1', 'e_type1'),
('e_type2', 'e_type2'),
('e_type3', 'e_type3'),
)
TEST_TYPE_CHOICES = (
('t_type1', 't_type1'),
('t_type2','t_type2'),
('others', 'others'),
)
name = models.CharField(max_length=200, unique=True)
executable = models.CharField(max_length=1023)
parameter_list = models.TextField(blank=True, default = "")
project_name = models.CharField(max_length=200, choices = PROJNAME_CHOICES, default="Name1")
executable_type = models.CharField(max_length=200, choices = EXECUTABLE_TYPE_CHOICES, default = "e_type1")
test_type = models.CharField(max_length=200, choices = TEST_TYPE_CHOICES, default = "t_type1")
created_by = models.CharField(max_length=200, default = "sb")
create_datetime = models.DateTimeField("testcase created on", auto_now = True)
My template:
<form method="post">{% csrf_token %}
<h1 >Edit Test Case:</h1>
<table>
<tr>
<th>Name:</th>
<th>executable:</th>
<th>parameter_list:</th>
</tr>
<tr>
<td><input type="text" id="id_name" name="name" value = "{{my_case.name}}"
placeholder="short_unique_string" required>
</td>
<td>
<input type="text" id="id_executable" name="executable" value = "{{my_case.executable}}"
placeholder="FilenameWithoutPath.py" required>
</td>
<td><textarea id="id_parameter_list" name="parameter_list" value = "{{my_case.parameter_list}}"
placeholder="Copy your parameter string here directly"></textarea>
</td>
</tr>
<tr>
<th>executable_type:</th>
<th>test_type:</th>
<th>project_name:</th>
<th>created_by:</th>
</tr>
<tr>
<td>
<select name="executable_type" id="id_executable_type" required>
{%for key, value in my_exetype %}
{%if my_case.executable_type == key %}
<option value={{value}} selected>{{key}}</option>
{%else%}
<option value={{value}}>{{key}}</option>
{%endif%}
{%endfor%}
</select>
</td>
<td>
<select name="test_type" id="id_test_type" required>
{%for key, value in my_ttype %}
{%if my_case.test_type == key %}
<option value={{value}} selected>{{key}}</option>
{%else%}
<option value={{value}}>{{key}}</option>
{%endif%}
{%endfor%}
</select>
</td>
<td>
<select name="project_name" id="id_project_name" >
{%for key, value in projnames %}
{%if my_case.project_name == key %}
<option value={{value}} selected>{{key}}</option>
{%else%}
<option value={{value}}>{{key}}</option>
{%endif%}
{%endfor%}
</select>
</td>
<td><input type="text" id="id_created_by" name="created_by" value = "{{my_case.created_by}}"
placeholder="some name like 'sb'" required></td>
</tr>
</table>
{% for i in form.errors %}
{{i}}
{% endfor %}
<br>
{% if form.errors %}
error!
{% endif %}
<input type="submit" value="Update">
</form>
MY issue: The page displays well. I changed something and clicked update. The page refreshed to unchanged page, without calling get_success_url() as I expected. I checked the database, record didn't update either. I checked the template again and again but didn't find error.
Following Selcuk advice, I add print form.errors. When the editing page is display, it prints all field names as error like below:
When I update, print as:
I'm not sure what's that means.
Related
I have a database with the name of the attached files
models.py
class UploadFile(models.Model):
user = models.ForeignKey(User,on_delete = models.CASCADE,related_name='file_created' ,verbose_name='Автор')
title = models.CharField(max_length=200, verbose_name='Заголовок')
# uploadedfile = models.FileField(upload_to='files/',null=True, verbose_name='Файл')
description = models.TextField(blank=True, verbose_name='Описание')
createdtime = models.DateField(auto_now_add=True, db_index=True, verbose_name='Дата создания')
price = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True, verbose_name='Цена')
number_course = models.IntegerField(null=True, blank=True, verbose_name='Курс')
number_semestr = models.IntegerField(null=True, blank=True, verbose_name='Семестр')
subjectt = models.CharField(max_length=200, null=True,verbose_name='Предмет')
type_materials = models.CharField(max_length=200,null=True, verbose_name='Тип работы')
institute = models.CharField(max_length=200, null=True, verbose_name='Институт')
def __str__(self):
return self.title
class Meta:
verbose_name = 'Загрузка файла'
verbose_name_plural = 'Загрузка файлов'
I need to make a filter on the table that is obtained when uploading a file:
Page with table:
<div style="float: right; margin-bottom: 10%; margin-top: 10%;" class="form-group row" data-aos="fade-up">
<form action="" method="post" style="width:90%">
{% csrf_token %}
<!-- {{form|crispy}}-->
<p><label class="form-label" for="{{ form.number_course.id_for_label }}">Курс: </label> {{ form.number_course }}</p>
<div class="form-error">{{ form.number_course.errors }}</div>
<p><label class="form-label" for="{{ form.number_semestr.id_for_label }}">Семестр: </label> {{ form.number_semestr }}</p>
<div class="form-error">{{ form.number_semestr.errors }}</div>
<p><label class="form-label" for="{{ form.subjectt.id_for_label }}">Дисциплина </label> {{ form.subjectt }}</p>
<div class="form-error">{{ form.subjectt.errors }}</div>
<p><select name = "type_materials" required class="form-select" aria-label="Тип материала">
<option selected>Тип материала</option>
<option value="Практические работы">Практические работы</option>
<option value="Лабораторные работы">Лабораторные работы</option>
<option value="Курсовые">Курсовые</option>
<option value="Дипломная работа">Дипломная работа</option>
<option value="Лекции">Лекции</option>
<option value="Диск с работами">Диск с работами</option>
<option value="Другое">Другое</option>
</select></p>
<p><select name = "institute" required class="form-select" aria-label="Институт">
<option selected>Институт</option>
<option value="ИВТИ">ИВТИ</option>
<option value="ГПИ">ГПИ</option>
<option value="ИЭЭ">ИЭЭ</option>
<option value="ИГВИЭ">ИГВИЭ</option>
<option value="ИнЭИ">ИнЭИ</option>
<option value="ИРЭ">ИРЭ</option>
<option value="ИЭТЭ">ИЭТЭ</option>
<option value="ИТАЭ">ИТАЭ</option>
<option value="ИЭВТ">ИЭВТ</option>
<option value="ЭнМИ">ЭнМИ</option>
<option value="Другой">Другой</option>
</select></p>
<div class="form-error">{{ form.institute.errors }}</div>
<button type="submit" class="btn btn-primary">Найти</button>
</form>
<div style="width:90%">
<br>
<table>
<tr>
<th>Заголовок</th>
<th>Описание</th>
<th>Институт</th>
<th>Курс</th>
<th>Семестр</th>
<th>Дисциплина</th>
<th>Цена</th>
<th>Тип материала</th>
<th>Файл</th>
</tr>
{% for bd in bdfiles %}
<tr>
<th>{{ bd.feed.title}}</th>
<th>{{ bd.feed.description }}</th>
<th>{{ bd.feed.institute }}</th>
<th>{{ bd.feed.number_course }}</th>
<th>{{ bd.feed.number_semestr }}</th>
<th>{{ bd.feed.subjectt }}</th>
<th>{{ bd.feed.price }}</th>
<th>{{ bd.feed.type_materials }}</th>
<th>Купить</th>
</tr>
{% endfor %}
</table>
</div>
</div>
And my searching code in views.py:
def buy_files(request):
bdfiles = FeedFile.objects.all()
upfiles = UploadFile.objects.all()
form = FileFilterForm(request.GET)
if form.is_valid():
if form.cleaned_data["number_course"]:
bdfiles = bdfiles.filter(number_course__exact = form.cleaned_data["number_course"])
if form.cleaned_data["number_semestr"]:
bdfiles = bdfiles.filter(number_semestr__exact = form.cleaned_data["number_semestr"])
if form.cleaned_data["subjectt"]:
bdfiles = bdfiles.filter(course__in = form.cleaned_data["subjectt"])
if form.cleaned_data["type_materials"]:
bdfiles = bdfiles.filter(course__in = form.cleaned_data["type_materials"])
return render(request, 'chat/files/buyfile.html', {'bdfiles': bdfiles, 'form':form})
But when I try to filter the data, nothing happens. I do not know how to make a search, for example, only by one item, for example, by course or by semester, and so on.
If you are using this for to do de filtering using the submit button then the issue is that the form is sending a POST request.
<form action="" method="post" style="width:90%">
And your view is filtering using the data passed as GET
form = FileFilterForm(request.GET)
You should create a for with a method="get" to make it work.
To make this easier you can use django-filter
Hi everyone! I want search by multiple categories, but my code is not working. When I type categories name, I got nothing. Can anyone help me?
'''views.py'''
class ExpenseListView(ListView):
model = Expense
paginate_by = 5
def get_context_data(self, *, object_list=None, **kwargs):
queryset = object_list if object_list is not None else self.object_list
form = ExpenseSearchForm(self.request.GET)
if form.is_valid():
name = form.cleaned_data.get('name', '').strip()
if name:
queryset = queryset.filter(name__icontains=name)
return super().get_context_data(
form=form,
object_list=queryset,
summary_per_category=summary_per_category(queryset),
get_per_year_month_summary=get_per_year_month_summary(queryset),
**kwargs)
def get_queryset(self):
queryset = super(ExpenseListView, self).get_queryset()
q = self.request.GET.get("q")
if q:
return queryset.filter(date__icontains=q)
return queryset
def get_gategory(request, pk_test):
category = Category.objects.get(id=pk_test)
orders = category.order_set.all()
order_count = orders.count()
myFilter = OrderFilter(request.GET, queryset=orders)
orders = myFilter.qs
context = {'category': category, 'orders': orders,
'order_count': order_count, 'myFilter': myFilter }
return render(request, 'expense_list.html',context)
'''May be my problem is in my vieews or in models. I m new in Django and dont nkow many things..'''
''' Here my models.py'''
class Category(models.Model):
class Meta:
ordering = ('name',)
name = models.CharField(max_length=50, unique=True)
def __str__(self):
return f'{self.name}'
class Expense(models.Model):
class Meta:
ordering = ('-date', '-pk')
category = models.ForeignKey(Category, models.PROTECT, null=True, blank=True)
name = models.CharField(max_length=50)
amount = models.DecimalField(max_digits=8, decimal_places=2)
date = models.DateField(default=datetime.date.today, db_index=True)
def __str__(self):
return f'{self.date} {self.name} {self.amount}'
'''html''
{% extends "base.html" %}
{% block content %}
add
<form method="get">
{{form.as_p}}
<button type="submit">search</button>
</form>
<hr>
{% if expenses %}
<form action="#" method="GET">
{% endif %}
<input type="text" name="q" placeholder="category">
<input type="text" name="q" placeholder="name">
<input type="submit" value="Search">
</form>
<hr>
<form method="GET" action={% url 'expenses:expense-list' %}>
{% csrf_token %}
From: <input type="date" name="q"/>
To: <input type="date" name="q"/>
From_category:
<select>
<option selected disabled="true"></option>
{% for obj in object_list %}
<option value="{{ obj.category }}">{{obj.category}}</option>
{%endfor%}
</select>
<button type="submit">search</button>
</form>
</div>
<br>
<table border="1">
<caption>Expenses</caption>
<thead>
<tr>
<th>no.</th>
<th>category</th>
<th>name</th>
<th>amount</th>
<th>date</th>
<th>actions</th>
</tr>
</thead>
<tbody>
{% for obj in object_list %}
<tr>
<td>{{ page_obj.start_index|add:forloop.counter0 }}.</td>
<td>{{ obj.category|default:"-" }}</td>
<td>{{ obj.name|default:"-" }}</td>
<td>{{ obj.amount|floatformat:2 }}</td>
<td>{{obj.date}}</td>
<td>
edit
delete
</td>
</tr>
{% empty %}
<tr>
<td colspan="5">no items</td>
</tr>
{% endfor %}
</tbody>
</table>
</form>
{% include "_pagination.html" %}
<hr>
<table border="1">
<caption>Summary per category</caption>
<tr>
{% for category, total in summary_per_category.items %}
<tr>
<td>{{category}}:</td>
<td>{{total|floatformat:2}}</td>
</tr>
{% endfor %}
</tr>
</table>
<hr>
<table border="2">
<caption>Summary per year-month </caption>
<tr>
{% for year, total_year in get_per_year_month_summary.items %}
<tr>
<td>{{year}}</td>
<td>{{total_year|floatformat:2}}</td>
</tr>
{% endfor %}
</tr>
</table>
{% endblock %}
'''urls'''
urlpatterns = [
path('expense/list/',
ExpenseListView.as_view(),
name='expense-list'),
path('expense/create/',
CreateView.as_view(
model=Expense,
fields='__all__',
success_url=reverse_lazy('expenses:expense-list'),
template_name='generic_update.html'
),
name='expense-create'),
path('expense/<int:pk>/edit/',
UpdateView.as_view(
model=Expense,
fields='__all__',
success_url=reverse_lazy('expenses:expense-list'),
template_name='generic_update.html'
),
name='expense-edit'),
path('expense/<int:pk>/delete/',
DeleteView.as_view(
model=Expense,
success_url=reverse_lazy('expenses:expense-list'),
template_name='generic_delete.html'
),
name='expense-delete'),
path('category/list/',
CategoryListView.as_view(),
name='category-list'),
path('category/create/',
CreateView.as_view(
model=Category,
fields='__all__',
success_url=reverse_lazy('expenses:category-list'),
template_name='generic_update.html'
),
name='category-create'),
path('category/<int:pk>/delete/',
DeleteView.as_view(
model=Category,
success_url=reverse_lazy('expenses:category-list'),
template_name='generic_delete.html'
),
name='category-delete'),
path('category/<int:pk>/update/',
UpdateView.as_view(
model=Category,
fields='__all__',
success_url=reverse_lazy('expenses:category-list'),
template_name='generic_update.html'
),
name='category-update'),
]
this is screen of my projects views
I'm trying to create an inventory management system. I'm having problems figuring out how to add multiple inventory items into my order from a table. I want to achieve this by selecting the item by the checkbox and also adding the quantity. I also eventually want to add a search bar to search through the table
html
<form method="POST" action="">
{% csrf_token %}
{% for field in form %}
<div class="form-group row">
<Label for="id_{{ field.name }}" class="col-2 col-form-label">{{ field.label }}</Label>
<div class="col-10">
{{ field }}
</div>
</div>
{% endfor %}
<table class="table table-striped">
<tbody>
{% for item in Inventory %}
<tr>
<td> <input type="checkbox" name="itemCheck" value="{{ item.pk }} "></td>
<td> <input name="itemQuantity"> </td>
<td> {{ item.name }} </td>
<td> {{ item.quantity }} </td>
<td> <span class="badge badge-pill badge-success">{{item.status}}</span></td>
<td> ${{ item.sale_price }} </td>
</td>
</tr>
{% endfor %}
</tbody>
</table>
views.py
def create_order(request):
order_form = OrderForm(request.POST)
if request.method == 'POST':
if formset.is_valid():
total = 0
order = Orders(total=total)
order.save()
order_form.save()
selected_items = request.POST.getlist('itemCheck')
print(selected_items) # This returns the primary keys of the selected items
context = {"form": order_form, "Inventory": Inventory.objects.all()}
return render(request, 'create_order.html', context)
models
class Inventory(models.Model):
name = models.CharField(max_length=128, blank=False)
...
def __str__(self):
return f"{self.id} - {self.name}"
class Orders(models.Model):
studio = models.CharField(max_length=64)
status = models.CharField(max_length=64, default="warehouse", blank=False)
total = models.DecimalField(max_digits=10, decimal_places=2)
class OrderEquipment(models.Model):
equipment = models.ForeignKey(Inventory, blank=False, on_delete=models.CASCADE)
order = models.ForeignKey(Orders, on_delete=models.CASCADE)
quantity = models.IntegerField(blank=False)
For the sake of simplicity, since you didn't post your formset and other code, I'm going to assume your HTML and formset are coming in correctly and just focus on the table/model loading. I have found the best way to load many items is to use bulk_create(). You may need to fidget around with the below code, but it should get you on the right track.
from django.db import transaction
try:
with transaction.atomic():
# I put cleaned_data below. You need to replace with your Orders data if different.
order = Orders.objects.create(**cleaned_data)
# Loop thru OrderEquipment Items. I'm guessing your 'selected_items' is the inventory data, (equipment and quantity).
orderequip_list = []
for equip in selected_items:
orderequip_list.append(OrderEquipment(order=order, **equip))
OrderEquipment.objects.bulk_create(orderequip_list)
except (IntegrityError, ObjectDoesNotExist):
order = None
I want to add all the columns in 1 algorithm for a search. If it is possible.
Something like this:
*UPDATE * ( i have update the views.py and search_table.html )
It is only searching correctly the url field. The id and the title anything i put in those fields it will give me the entire table.
views.py
def search_table(request, pk):
table_name = Crawledtables.objects.get(id=pk)
t = create_model(table_name.name)
q = request.GET['q']
if q is not None:
query = t.objects.filter(Q(id__icontains=q) | Q(title__icontains=q) | Q(url__icontains=q))
return render(request, 'search/results_table.html', {'tbl_name': table_name,
'details': query,
'query': q})
else:
return HttpResponse("Please submit a search term!")
results_table.html
<strong> {{ tbl_name }}</strong>
<p> You searched for: <strong>{{ query }}</strong></p>
{% if details %}
<p> Found {{ details|length }}</p>
<div class="row">
<table class="table table-bordered sortable">
<thead>
<tr>
<th>Id</th>
<th>Title</th>
<th>Url</th>
</tr>
</thead>
<tbody>
{% for lists in details %}
<tr>
<td>{{ lists.id }}</td>
<td>{{ lists.title }}</td>
<td>{{ lists.url }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p> No results found</p>
{% endif %}
{% endblock %}
search_table.html
{% if tbl_name %}
<form action="/search/{{ tbl_name.id }}/results" method="GET">
{% endif %}
<input type="text" name="q" placeholder="Id">
<input type="text" name="q" placeholder="Title">
<input type="text" name="q" placeholder="Url">
<input type="submit" value="Search">
</form>
UPDATE
models.py
def create_model(db_table):
class CustomMetaClass(ModelBase):
def __new__(cls, name, bases, attrs):
model = super(CustomMetaClass, cls).__new__(cls, name, bases, attrs)
model._meta.db_table = db_table
return model
class AllTables(models.Model):
__metaclass__ = CustomMetaClass
id = models.IntegerField(primary_key=True)
title = models.CharField(db_column='Title', blank=True, null=True, max_length=250)
url = models.CharField(db_column='Url', unique=True, max_length=250, blank=True,
null=True)
created_at = models.DateTimeField(db_column='Created_at')
return AllTables
Q objects are used to make complex logical queries.
use in syntax: AND (&) and OR (|)
from django.db.models import Q
t.objects.filter(Q(id__icontains=q_id) | Q(title__icontains=q_title) | Q(url__icontains=q_url))
Lets say I have a model
models.py
class user:
name = models.CharField(max_length=25)
class job:
job_name = models.CharField(max_length=25)
class user_job:
user = models.ForeignKey('user')
job = models.ForeignKey('job')
forms.py
jobs = (
('0', 'a'),
('1', 'b'),
('2', 'c'),
)
class searchForm:
box = forms.ModelMultipleChoiceField(
choices = jobs,
widget = forms.CheckboxSelectMultiple(),
label = 'Search',
)
I can search for users that have job 'a' with
user_job.objects.filter(job__exact = 'a') ...
I tried to search for users that have both job 'a' and job 'c' like so
search_q = user_job.objects.filter(job__exact = 'a')
search_q = search_q.filter(job__exact = 'c')
but I get all users that have job 'a' or job 'c', and I need all users that have both jobs.
Is there a way I can filter it through Django, or do I need to filter on one job and then iterate through the results and check for the 2nd job?
You'll probably find it easier to search from the User model since what you want is a list of Userss who have both jobs. Django automatically sets up properties on your models that allow you to access related models both from model instances and in DB queries.
Assuming you set up your models like so:
from django.db import models
class User(models.Model):
name = models.CharField(max_length=25)
def __repr__(self):
return '<User: %s>' % self.name
class Job(models.Model):
name = models.CharField(max_length=25)
def __repr__(self):
return '<Job: %s>' % self.name
class UserJob(models.Model):
user = models.ForeignKey(User)
job = models.ForeignKey(Job)
def __repr__(self):
return '<UserJob: %s %s>' % (self.user.name, self.job.name)
And populate it as follows:
u1 = User.objects.create(name='u1')
u2 = User.objects.create(name='u2')
u3 = User.objects.create(name='u3')
a = Job.objects.create(name='a')
b = Job.objects.create(name='b')
c = Job.objects.create(name='c')
UserJob.objects.create(user=u1, job=a)
UserJob.objects.create(user=u2, job=a)
UserJob.objects.create(user=u2, job=b)
UserJob.objects.create(user=u3, job=a)
UserJob.objects.create(user=u3, job=c)
The following query will return you user 3, which is the only user who has both "Job a" and "Job c":
u = User.objects.filter(userjob__job=a).filter(userjob__job=c)
(or, if you prefer to refer to the jobs by name rather than Job instance):
u = User.objects.filter(userjob__job__name='a').filter(userjob__job__name='c')
You can see how Django is allowing you to traverse the related fields from the User model to the UserJob model with the double underscore notation (the Django docs on this are here: http://docs.djangoproject.com/en/1.2/topics/db/queries/#lookups-that-span-relationships.
Once you get the User object back, you can similarly access the UserJob instances using the relationship properties that Django adds to the model:
u = User.objects.filter(userjob__job__name='a').filter(userjob__job__name='c')
jobs = u.userjob_set.all()
pip install django-filter
Then add django-filter in your install apps:
'django_filters'
Then create a new file like filter.py
import django_filters
from rent.models import Rent
from django.views import View
class RentFilter(django_filters.FilterSet):
class Meta:
model = Rent
fields = [
'name', 'bed_room', 'bath_room', 'rent_location', 'types'
]
After that import RentFilter in your views.py then follow the step:
class BookingFilerListView(View):
def get(self, request):
booking_list = Booking.objects.all()
booking_filer = BookingFilter(request.GET, queryset=booking_list)
template = 'booking/booking_filter.html'
ctx = {'result': booking_filer}
return render(request, template, ctx)
Finally, in your booking_filter.html template look like this:
<form method="get">
<div class="card-body">
<div class="form-group">
<label for="phone_number">Phone Number</label>
<input type="text" class="form-control" placeholder="Phone Number" name="phone_number">
</div>
<div class="form-group">
<label for="transaction_id">Transaction ID</label>
<input type="text" class="form-control" placeholder="Transaction ID" name="transaction_id">
</div>
<div class="form-group">
<label for="booking_date">Booking Date</label>
<input type="date" class="form-control" placeholder="Booking Date" name="booking_date">
</div>
<div class="form-group">
<label for="status">Booking Date</label>
<select class="form-control" name="status" id="status">
<option value="0">PENDING</option>
<option value="1">CANCEL</option>
<option value="2">PROGRESS</option>
<option value="3">DONE</option>
</select>
</div>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-success">Filter Booking</button>
<button type="reset" class="btn btn-danger">Reset</button>
</div>
</form>
Print the output in your template bottom:
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Phone Number</th>
<th>Transaction ID</th>
<th>Booking Date</th>
</tr>
</thead>
<tbody>
{% if result %}
{% for obj in result.qs %}
<tr>
<td>{{ obj.phone_number }}</td>
<td>{{ obj.transaction_id }}</td>
<td>{{ obj.booking_date }}</td>
</tr>
{% endfor %}
{% else %}
{% endif %}
</tbody>
</table>