Hello, i am having problem in figuring out why my request.GET in htmx is returning empty
models.py
class Order(models.Model):
order_id = models.AutoField(primary_key=True)
weekly = models.ForeignKey(Weekly, on_delete=models.CASCADE, null=True, blank=True)
user = models.ForeignKey(CustomUser, on_delete=models.PROTECT, null=True, blank=True)
total_price = models.DecimalField(max_digits=7, decimal_places=0, null=True, blank=True)
date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)
STATUS_CHOICES = {
'new':'New',
'ongoing':'Ongoing',
'done': 'Done',
}
status = models.CharField(choices=STATUS_CHOICES, default='new', max_length=20)
active = models.BooleanField(default=False)
class Meta:
ordering = ['order_id']
def __str__(self):
return f'{str(self.weekly.name)} {self.status} {self.user} Delivery for {str(self.weekly.date_delivery)}'
views.py
class OrderDateView(ListView):
template_name = 'polls/order_date_list.html'
model = Order
context_object_name = 'orders'
def get_queryset(self):
print(self.request)
print(self.request.GET)
return Order.objects.all()
def get_template_names(self):
is_htmx = self.request.headers.get('HX-Request') == 'true'
if is_htmx:
return 'polls/orders_date.html'
return self.template_name
order_date_list.html
{% extends 'base.html' %}
{% load static %}
{% block title %}Order Date{% endblock %}
{% block content %}
<section class="container">
<div class="d-flex justify-content-end gap-3">
<label for="start_date">Start</label>
<input id="start_date" type="date" name="start_date"/>
<label for="end_date">End</label>
<input id="end_date" type="date" name="end_date"/>
<button
class="btn btn-secondary"
hx-get="{% url 'polls:order_date' %}"
hx-target="#orderDate"
hx-swap="outerHTML"
>Search</button>
</div>
{% include 'polls/orders_date.html' %}
</section>
{% endblock %}
orders_date.html
<section id="orderDate">
<div>
<div class="row bg-secondary my-3">
<div class="col-md-6 col-5 text-center"><h3>Order Date</h3></div>
<div class="col-md-4 col-2 text-center"><h3>Status</h3></div>
<div class="col-md-2 col-5 text-end"><h3>Total Price</h3></div>
</div>
{% for order in orders %}
<p>{{order}}</p>
{% endfor %}
</div>
</section>