Reputation: 197
Scenario:I want to make a page for available slots for booking ,for which I want print time slot for 1 hour that is from i To i+1 and color it according to the availability. I am newbie to django and can't figure out the way to make a calendar and that is why I am printing time values in HTML template. Is there any other way to make this page and also is printing 'i+1' possible.
Views.py
@login_required
def slots(request):
k={ 'pro':range(8,17)
}
return render(request, 'login/slots.html',k)
slots.html
{% for i in pro %}
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td id="demo">{{ i }} to {{ i+1 }}</td>
</tr>
{% endfor %}
I know this might be a silly question but I am not able to figure it out, any help is appreciated.
Upvotes: 3
Views: 2136
Reputation: 5070
There is a built-in filter in Django template called add
. You can add something to a value in templates using {{ value|add:"2" }}
.
In this case specifically, try:
<td id="demo">{{ i }} to {{ i|add:"1" }}</td>
Upvotes: 2