[Answered ]-Django forms: could not convert string to float

2👍

Fetch the values from form.cleaned_data, instead of using form['fieldname'].data

For example:

date = form.cleaned_data['date']

See the docs on processing the data from a form for further details.

0👍

There might be more than one problem, but the most obvious one that stands out is this:

price = modes.FloatField(..., blank=False, ...)

in your Session model.

Set blank=True to allow the form field to be blank. The ORM will then use your default=0 when saving if the form field was blank.

Leave a comment