For example, DateField fields use a Python datetime object to store data. Databases don’t store datetime objects, so the field value must be converted into an ISO-compliant date string for insertion into the database.
track = models.Track.objects.get(pk=instance.pk)
class Track(models.Model):
profile = models.ForeignKey(UserProfile)
distance = models.IntegerField()
transport = models.SmallIntegerField()
type = models.SmallIntegerField()
ident = models.DateTimeField()
time_start = models.DateTimeField()
time_end = models.DateTimeField()
time_saved = models.DateTimeField(auto_now_add=True)
max_alt = models.IntegerField()
min_alt = models.IntegerField()
avg_speed = models.SmallIntegerField()
max_speed = models.SmallIntegerField()
published = models.BooleanField(default=False)
def __str__(self):
return self.id
@receiver(post_save, sender=Track)
def track_save_handler(sender, instance, **kwargs):
track = instance
logger.debug("Time start is %s" % track.time_start.__class__.__name__)
logger.debug("Type of time start is %s" % type(track.time_start))