In my form I am expecting the user to enter a two part time...HH:mm
but when the update form is loaded the duration field value is returned as HH:mm:ss
So when saving a value:
duration: 13:00
When editing the form the initial data will be:
duration 13:00:00
When saving that I get an ValidationError
as that is not a format I want to accept.
if ':' in duration:
try:
(hours, minutes,) = duration.split(':')
except ValueError:
self.add_error(
'duration',
_("Invalid duration: {}".format(duration))
)
return duration
Is there a way to only show the HH:mm
format for all places I am showing the DurationField
or is it better to just set it in the initial data of the form?