admin管理员组文章数量:1240594
I created a calendar with dates where appointments can be made. I then created a form to select appointments. I want each time an appointment is made, it to be grayed out for the exact day and time it was made. For March 2, 2025 I booked an appointment at 9am, for January 24, I booked an appointment at 8am and for March 6, 2025, I booked an appointment at 2:15pm. However, as you can see in the picture, when I click on March 2, 2025, the times 8am, 9am and 2:15pm are all grayed out even though I used them for different days. Thanks in advance #**********************************
def formatday(self, day, rdvs):
select_hour = RdvForm()
select_dat = Rdv.objects.all().values()
p = len(select_dat)`enter code here`
rr =len(select_hour['start_time'])
ls_h = []
ls_d =[]
ls_dd=[]
# add value in list
for i in range(p):
ls_h.append(select_dat[i]["start_time"])
for lis_d in range(p):
f = str(select_dat[lis_d]["select_date"])
ls_d.append(f[:7])
#list day year
for dd in range(p):
ff = str(select_dat[dd]["select_date"])
ls_dd.append(int(ff[8:]))
year_month_curent =str (self.year)+'-'+str("{:02}".format(self.month))
htm = f'<select name="start_time" id="id_start_time">'
for i in range(rr):
if select_hour['start_time'][i].data['value'] in ls_h and year_month_curent in ls_d and day in ls_dd:
htm+= f'<option class="{i}" disabled="disabled" value="{select_hour['start_time'][i].data["value"]}">{select_hour['start_time'][i].data["value"]}</option>'
else:
htm+= f'<option value="{select_hour['start_time'][i].data["value"]}">{select_hour['start_time'][i].data["value"]}</option>'
htm+=f'</select>'
#*****************
for i in range(rr):
if day != 0:
return f"<td><span class='date' style='font-weight:bold'
{'{:02}'.format(day)}</span><br> {htm} </td>"
return '<td></td>'
本文标签: How to disable the options in select with DjangoStack Overflow
版权声明:本文标题:How to disable the options in select with Django - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740057178a2222425.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论