Python Forum
How to iterate a PlainLocationField object and fetch some values?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to iterate a PlainLocationField object and fetch some values?
#1
Hi All,

I am doing one mistake in my code but unable to solve this.

from location_field.models.plain import PlainLocationField
class Store(OwnedModel):
    address = models.TextField(default='Mumbai')
    location = PlainLocationField(based_fields=['address'], zoom=7, null=True)
	
	@property
    def latitude(location):
        if not location:
            return
        latitude = location[1]
        return latitude

    @property
    def longitude(location):
        if not location:
            return
        longitude = location[0]
        return longitude
Issue in above code is PlainLocationField object does not support indexing.
So I am unable to return latitude,longitude from location.
Can anyone please help me to solve this?
Reply


Messages In This Thread
How to iterate a PlainLocationField object and fetch some values? - by PrateekG - Jun-21-2018, 06:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Printing out incidence values for Class Object SquderDragon 3 361 Apr-01-2024, 07:52 AM
Last Post: SquderDragon
  AttributeError: 'list' object has no attribute 'values' ilknurg 4 15,219 Jan-19-2022, 08:33 AM
Last Post: menator01
  Object already contains values when created Stef 4 2,437 Aug-20-2020, 09:42 AM
Last Post: Stef
  How does a single object see all the values inside it? jenniferruurs 1 1,878 Oct-01-2019, 04:57 PM
Last Post: stullis
  Unable to fetch Outlook Mail body pramodb35 0 4,189 Jul-25-2018, 07:08 AM
Last Post: pramodb35
  Regular expression to fetch comments in C using Python pikkip 4 4,951 Jan-24-2017, 09:21 AM
Last Post: wavic

Forum Jump:

User Panel Messages

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