(Jun-20-2018, 10:08 AM)gontajones Wrote: With "null=True" you allow empty values.
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
Thanks! I have put try-except in my code and able to see following print messages in logs-
Location: 8 SHENTON WAY #43-01 AXA TOWER Singapore
Exception: not enough values to unpack (expected 2, got 1)
Same I did for longitude function but no any message was printed; it means longitude field is missing here.
It seems 'PlainLocationField' is not working properly here.