Python Forum
How to fetch latitude,longitude from location and save them separately in db(Django2)
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to fetch latitude,longitude from location and save them separately in db(Django2)
#1
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:
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')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to auto fill latitude and longitude fields in Django2.0.6? PrateekG 9 5,695 Jun-21-2018, 11:55 AM
Last Post: gontajones
  Unable to fetch product url using BeautifulSoup with Python3.6 PrateekG 6 4,142 Jun-05-2018, 05:49 PM
Last Post: PrateekG
  Not able to fetch data from a webpage sumandas89 3 4,703 Dec-21-2017, 08:30 AM
Last Post: sumandas89
  How do I fetch values from db to Select Options using Flask? progShubham 2 17,638 Jul-25-2017, 05:52 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020