Closed
Description
I've followed the docs on the integration as specified in README file.
Now, whenever I type an address, say, "10900 Euclid Ave, Cleveland, OH 44106, USA" I get an error "Select a valid choice. That choice is not one of the available choices."
- Bitbucket: https://bitbucket.org/kmike/django-easy-maps/issue/2
- Originally reported by: Ahmed Youssef
- Originally created at: 2011-04-04T01:05:00.816
Activity
bashu commentedon May 30, 2015
The error seems to be from the ChoiceField or its subclass and there are no ChoiceFields mentioned in README. I've just entered this address to the form from one of my projects and it works fine ( http://pix.am/uMa8.png ).
Could you please provide more details? Are you using django admin? How is your 'address' field defined?
Original comment by: Mikhail Korobov
bashu commentedon May 30, 2015
Yes, I'm trying to use it in the admin interface
Well, there's a property model related as defined
{{{
class Property(models.Model):
address=models.ForeignKey(Address)
....
}}}
and here's PropertyAdmin
{{{
class PropertyAdmin(admin.ModelAdmin):
list_display = ('ref', 'property_type', 'address', 'town', 'living_space', 'land_space', 'is_renting', 'price', 'published')
search_fields= ( 'is_renting', 'title', 'property_type', 'town', 'department', 'created_at')
date_hierarchy = 'created_at'
list_per_page=20
}}}
Now, it appears that the address field puts the generated address id when i press [+] to add a new address.
How can I put the address not its id in the field ?
Thanks
Original comment by: Ahmed Youssef
bashu commentedon May 30, 2015
It may be not clear from the readme, but address field should be CharField or TextField, not a ForeignKey to Address model.
Address model should be considered implementation detail. Its sole purpose is to avoid using geocoder for each request, that's a kind of persistent cache. Its description is included in readme only because it can be useful for custom map templates.
If text is changed in 'address' field then new Address instance will be auto-created on first map access.
Thanks for reporting this issue. I've just re-read the readme and it is indeed not clear what is 'address' field supposed to be.
Original comment by: Mikhail Korobov
bashu commentedon May 30, 2015
Clarified readme. Fix #2.
→ <<cset 8ced16c04330>>
Original comment by: Mikhail Korobov
bashu commentedon May 30, 2015
but how to use it as a foreign key, what would be the approach to have it as a property to another model?
Original comment by: Anonymous