Hi,

First I really suggest you to take a look at Django GIS functionality. It
requires few libs to be installed but gives you tons of functionality.
Including fields that can show geometry on map.

Next problem is that you want to convert physical address to coordinates.
Process is called geocoding and there exists several services and libraries
you can use.

Finally the hard part - just combine those two and you get what you're
asking for.


to 21. kesäk. 2018 klo 13.44 prateek gupta <gupta...@gmail.com> kirjoitti:

> Hi All,
>
> I need your help in one task.
> I have created a address form in Django 2.0.6 + Python3.6.
> In this form once user entered the address, the location field is auto
> filled with latitude,longitude as below screen shot-
>
>
> <https://lh3.googleusercontent.com/-zFrYeNJBvQk/Wyt_0NYnnyI/AAAAAAAAMLI/Fk7a7XvlucQeiRCYEN15WffXrp6WITtYwCLcBGAs/s1600/addStore.JPG>
>
> Now I want to write a python function which can fetch Latitude and
> Longitude values from the Location field and can save them in respective
> Latitude/Longitude fields.
>
> My models.py code is as below:
> class Store(models.Model):
>     postal_code = models.CharField(max_length=6)
>     address = models.TextField()
>     location = PlainLocationField(based_fields=['address'], zoom=7,
> null=True)
>     phone = models.CharField(max_length=60, blank=True, null=True)
>     latitude = models.FloatField()
>     longitude = models.FloatField()
>     class Meta:
>         managed = False
>         db_table = 'store'
>
> admin.py:
>
> class StoreAdmin(admin.ModelAdmin):
>     list_display = ('postal_code', 'address','phone', 'latitude', 'longitude')
>
>
> Can anyone help me to achieve this functionality?
>
> --
> 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/c453ba82-7e0a-4fc1-8c8e-0a588b857627%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c453ba82-7e0a-4fc1-8c8e-0a588b857627%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAHn91ocDijwVPxXZ-ynGd%2BFK%3D%2B%3DF4Hbcqaeci-hbYRQQGwhD-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to