Jun-21-2018, 04:40 AM
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-location field example
I need to fetch the values of latitude/longitude from this location field and save into respective latitude and longitude columns in db.
How can I achieve this?
My current code-
models.py:
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-location field example
I need to fetch the values of latitude/longitude from this location field and save into respective latitude and longitude columns in db.
How can I achieve this?
My current code-
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')