I have used the answers from similar questions on here to create this however, when getting the fields I get an SQL insert error
IntegrityError: (sqlite3.IntegrityError) NOT NULL constraint failed: orders.pickupTime
this is the checkout.html page
<form class="form" action="" method="post" novalidate>
{{ form.hidden_tag() }}
<div class="single-widget">
<h2>Payments</h2>
<div class="content">
<div class="checkbox">
<label class="checkbox-inline" for="2"><input name="news" id="2" type="checkbox"> Cash On Delivery</label>
</div>
</div>
</div>
<div class="single-widget">
<div class="form-group">
<h2>Collection Time<span>*</span></h2>
{{ form.pickUpTime(size=32) }}
</div>
</div>
<div class="col-12">
<div class="form-group button">
<button type="submit" class="btn ">{{ form.submit() }}</button>
</div>
</div>
</form>
This is what is in my main checkout function and the collection time variable is empty even though ive imported timeChoices from forms.py
if form.validate_on_submit():
collectionTime = dict(timeChoices).get(form.pickUpTime.data)
Here is my forms.py
timeChoices = [(1, '7:00'), (2, '7:30'), (3, '8:00'), (4,'8:30'),(5,'9:00'), (6,'9:30')]
class CheckoutForm(FlaskForm):
pickUpTime = SelectField(u'Pick Up Time', choices=timeChoices, validators=[DataRequired()])
submit = SubmitField('Checkout')
question from:
https://stackoverflow.com/questions/65901008/getting-selectfield-from-wtf-forms-flask 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…