Jun-20-2018, 10:08 AM
With "null=True" you allow empty values.
So, test its content before the split:
So, test its content before the split:
from location_field.models.plain import PlainLocationField class Store(OwnedModel): building = models.ForeignKey(Building, related_name='building', on_delete=models.SET_NULL, blank=True, null=True) postal_code = models.CharField(max_length=6) address = models.TextField(default='Singapore') location = PlainLocationField(based_fields=['address'], zoom=7, null=True) @property def get_lat_log(self): latitude = '' longitude = '' try: print('Location: ' + str(self.location)) # DEBUG latitude, longitude = self.location.split(',') except Exception as e: print('Exception: ' + str(e)) return latitude,longitude def __str__(self): return self.location