Django预约表

2024-04-20 11:25:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在创建一个表单,用户可以在其中单击一个时间段并保留该时间段。共有5列,一周中的每一天(周一、周二、周三等)各一列,有5行时隙(下午3点、下午4点、下午5点、下午6点、晚上7点)。你知道吗

每个时隙代表一个无线电输入复选框选项。下面的示例只有两列。你知道吗

如何将单选输入按钮1-6和7-12分为两个不同的块。你知道吗

表单.py

class AppointmentForm(forms.Form):
One = 1
Two = 2
Three = 3
Four = 4
Five = 5
Six = 6
SEVEN = 7
EIGHT = 8
NINE = 9
TEN = 10
ELEVEN = 11
TWELVE = 12
TYPE_CHOICES = (
    (One, '3:00pm'),
    (Two, '3:45pm'),
    (Three, '4:30pm'),
    (Four, '5:15pm'),
    (Five, '6:00pm'),
    (Six, '6:45pm'),
    (SEVEN, '3:00pm'),
    (EIGHT, '3:45pm'),
    (NINE, '4:30pm'),
    (TEN, '5:15pm'),
    (ELEVEN, '6:00pm'),
    (TWELVE, '6:45pm')

)
appointment_time = forms.ChoiceField(
        choices=TYPE_CHOICES,
        label="Appointment times",
        widget=forms.RadioSelect,
        required=True,
         )

任命表格.html

<form action="" method="post">
  {% csrf_token %}
  {{ form|crispy }}
  <label for="id_id_appointment_time_0_1" class="form-check-label">1:00pm</label>
  <input class="btn btn-success-alt " type="submit" value="Submit">
</form>

正在尝试创建此I am trying to create the this

这就是我所处的位置 This is what I have


Tags: form表单formsonelabelclassthreefour