1๐
I think you are on the right track in using the form to validate your data. However, your input is failing the validation test simply because the input data, formatted as a time value, is not the integer that your model requires.
You should use an unbound field in the form (or an unbound form) that accepts the data as entered โ maybe as a character field. Then, use the clean method for this unbound field to confirm that the data can be converted (based on format and/or value). The actual conversion should happen in the view logic, perhaps in the form_valid() method.
1๐
Laptime is a time and if you expect the user to enter it in the format โ1:54.363โ the right field to use is TimeField
Validates that the given value is either a datetime.time or string
formatted in a particular time format
It seems that you are storing them in the database as microseconds. You would then need to check the form.is_valid() method and do the convertion either using the date time function or split and arithmatic.
.
- [Answered ]-How improve this django view code?
- [Answered ]-Django makemigrations error when there are 3 custom model in a models.py
- [Answered ]-Proxy redirecting websockets and http to the same (unix) socket
- [Answered ]-Django Q&Q versus filter.filter
- [Answered ]-Annotate causes ProgrammingError: must appear in the GROUP BY clause or be used in an aggregate function