I have a custom TimeSelector Django form widget that aggregates three select widgets into a single time value. Here's its value_from_datadict
method:
def value_from_datadict(self, data, files, name):
hour = int(data.get(self.hour_field % name))
minute = int(data.get(self.minute_field % name))
am_pm = data.get(self.am_pm_field % name)
if am_pm == 'PM':
hour += 12
return time(hour, minute)
This works, except that the returned datetime.time() instance is being coerced into a string somewhere in the form's clean() machinery. Any idea where or why?