Hi All,

I have created a model in Django 2.0.6+Python 3.6 which maps to a table in 
Database i.e. store table
This store table has columns- id, name, address, location, latitude, 
longitude.

Currently user don't have to manually fill the location field, it is filled 
with latitude,longitude based on the address entered. For this purpose I am 
using following package in Django- django-location-field 
<https://github.com/caioariede/django-location-field>

I need to fetch the values of latitude/longitude from this location field 
and save into respective latitude and longitude columns in db.
Currently in DB only location field is saved with latitude,longitude values.

How can I achieve this?

My Code is as below-

models.py:
from location_field.models.plain import PlainLocationField
class Store(OwnedModel):
   name = models.CharField(max_length=100)
   address = models.TextField(default='Mumbai')
   location = PlainLocationField(based_fields=['address'], zoom=7, null=True
)
    class Meta:
       managed = False
       db_table = 'store'

admin.py:
class StoreAdmin(admin.ModelAdmin):
   list_display = ('id', 'name', 'address')


-- 
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/c2dc13d9-3c0b-4bb0-845e-82f05f8d7ad6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to