1π
β
I donβt think this is possible only with the templating language unless you write a custom tag for this.
But this can be easily achieved with 3 lines of python in your view:
times = []
for i in range(0, 24*4):
times.append((datetime.combine(date.today(), time()) + datetime.timedelta(minutes=15) * i).time().strftime("%I:%M %p"))
in your template:
{% for time in times %}
<option>{{ time }}</option>
{% endfor %}
π€Ponytech
Source:stackexchange.com