The TimeRecord model has the following time field to store a time record for an athlete:
time = models.CharField(max_length=15, help_text='Time in minutes:seconds.milliseconds format')
This field was originally designed like this (as a CharField) to ensure that the time was provided with the format [M:]S.mm since we were not aware of Django providing a data type allowing us to do this.
The issue with this time representation is that getting the best time for a given athlete (an athlete can have many time records) will involve extra work since the time is stored as string instead of a numeric value. This will be an issue when dealing with operations.
Django provides the DurationField for storing periods of time.
We need to update the field type for time from CharField to DurationField.
The
TimeRecord
model has the following time field to store a time record for an athlete:time = models.CharField(max_length=15, help_text='Time in minutes:seconds.milliseconds format')
This field was originally designed like this (as a
CharField
) to ensure that the time was provided with the format [M:]S.mm since we were not aware of Django providing a data type allowing us to do this. The issue with this time representation is that getting the best time for a given athlete (an athlete can have many time records) will involve extra work since the time is stored as string instead of a numeric value. This will be an issue when dealing with operations.Django provides the DurationField for storing periods of time.
We need to update the field type for
time
from CharField to DurationField.