Overwrite save method with conversion from float to string
问题 I'm using django-mapbox-location-field and I need to save automatically the data from LocationField() into another field named coordinates . This is my model: class AddPoint(models.Model): point = LocationField() coordinates = models.CharField( max_length=50, blank=True, null=True, ) def save(self, *args, **kwargs): lat = self.point[0] lon = self.point[1] lon_lat = str(lon) + ', ' + str(lat) self.coordinates = lon_lat super(AddPoint, self).save(*args, **kwargs) Everytime I try to add a point