Fixed date vs datetime
This commit is contained in:
parent
1998fcb7d8
commit
4c97bd86db
|
@ -139,12 +139,11 @@ class CreatePitstopForm(Form):
|
||||||
def create_pit_stop_form():
|
def create_pit_stop_form():
|
||||||
last_pitstop = Pitstop.query.order_by(Pitstop.id.desc()).first()
|
last_pitstop = Pitstop.query.order_by(Pitstop.id.desc()).first()
|
||||||
if last_pitstop is None:
|
if last_pitstop is None:
|
||||||
last_pitstop = Pitstop(0, 0, datetime.now())
|
last_pitstop = Pitstop(0, 0, date.today())
|
||||||
|
|
||||||
form = CreatePitstopForm()
|
form = CreatePitstopForm()
|
||||||
form.set_pitstop(last_pitstop)
|
form.set_pitstop(last_pitstop)
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
|
|
||||||
new_stop = Pitstop(form.odometer.data, form.litres.data, form.date.data)
|
new_stop = Pitstop(form.odometer.data, form.litres.data, form.date.data)
|
||||||
sqldb.session.add(new_stop)
|
sqldb.session.add(new_stop)
|
||||||
sqldb.session.commit()
|
sqldb.session.commit()
|
||||||
|
@ -153,7 +152,7 @@ def create_pit_stop_form():
|
||||||
# dynamically set values
|
# dynamically set values
|
||||||
form.odometer.default = last_pitstop.odometer
|
form.odometer.default = last_pitstop.odometer
|
||||||
form.litres.default = last_pitstop.litres
|
form.litres.default = last_pitstop.litres
|
||||||
form.date.default = datetime.now()
|
form.date.default = date.today()
|
||||||
form.process()
|
form.process()
|
||||||
return render_template('newPitStopForm.html', form=form)
|
return render_template('newPitStopForm.html', form=form)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue