我正在为我的大学开发一个出租网站。我正在显示一个日历,用户可以在其中查看工具是否已租用,保留或可用。如果是租用或保留,日历的<td>
应该显示为红色。我的问题是我只设法为租用工具的开始日期着色,而没有为直到结束日期的日期着色。我该如何实现?
我使用Python Html日历,这是我目前为单元格着色的代码的样子:
def formatday(self, day, reservations):
reservations_per_day = reservations.filter(start_time__day=day)
d = ''
for reservation in reservations_per_day:
d += f'<li> {reservation.tool} </li>'
d += f'<li> {reservation.reservation_status} </li>'
d += f'<li> {reservation.start_time} </li>'
d += f'<li> {reservation.end_time} </li>'
if day != 0:
for reservation in reservations_per_day:
if reservation.reservation_status == 'reserved' or reservation.reservation_status == 'rent':
return f"<td bgcolor='indianred'><span class='date'>{day}</span><ul> {d} </ul></td>"
return f"<td ><span class='date'>{day}</span><ul> {d} </ul></td>"
return '<td></td>'