I have a model table like above which contains two columns on which dates on which an item is being sold in a month.
I want to show the entire month table in Django template instead of showing only the dates of sale, and on each day showing "yes" if the sale is there and keeping blank if no sale is there on that day. I.e How to iterate in Template through all the days in a month.
How the code should be in Django "views.py" and in Template
models.py
class SaleDates(models.Model):
date_of_sale = models.DateTimeField(blank=True, null=True)
sold_choices = (
('yes', 'yes'),
('no', 'no'),
)
sold_status = models.CharField(max_length=9, choices=sold_choices,)
template.html
{% for item in list %}
{% if forloop.first %}
<table class="table table-hover table-bordered">
<tr>
<th>Sl.NO</th>
<th>date</th>
<th>details</th>
</tr>
{% endif %}
<tr>
<td>
{{ forloop.counter }} <br/>
</td>
<td> {{ item.date_of_sale }}</td>
<td>
{{ item.sold_status }}
</td>
</tr>
{% if forloop.last %}
</table>
{% endif %}
{% empty %}
{% endfor %}
th
s for each day of the month 1-28/31? My first though is that this is going to be a huge table