Hi All,

I have a store address form in Django which have fields like- name, 
address, location, latitude, longitude etc.
I am autofilling the latitude, longitude fields based on address with the 
help of django package-https://github.com/caioariede/django-location-field


In django view after the form submisson I am able to see both fields values-


<https://lh3.googleusercontent.com/-Ei3fTveJ7oA/Wytkan_rUDI/AAAAAAAAMK8/1qyuFD_pqeUcP34P8Uvt3JJ5YoCLASOvACLcBGAs/s1600/django.JPG>


Issue is in database , latitude/longitude values are blank.

What I am doing wrong here?


models.py-

from location_field.models.plain import PlainLocationFieldclass 
Store(OwnedModel):
  address = models.TextField(default='Mumbai')
  location = PlainLocationField(based_fields=['address'], zoom=7, null=True)

  @property
  def latitude(self):
      if not self.location:
          return
      latitude, _ = self.location.split(',')
      return latitude

  @property
  def longitude(self):
      if not self.location:
          return
      _, longitude = self.location.split(',')
      return longitude

  class Meta:
      managed = False
      db_table = 'store'


admin.py-

class StoreAdmin(admin.ModelAdmin):
  list_display = ( 'address', 'latitude','longitude')
  readonly_fields = ('latitude', 'longitude',)


I am using Django2.0.6,Python3.6,Mysql

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e4d3a1f7-c618-4f2b-979c-3e258f0c5bec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to