Skip to content

Select a valid choice. That choice is not one of the available choices. #22

Closed
@bashu

Description

@bashu

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."


Activity

bashu

bashu commented on May 30, 2015

@bashu
OwnerAuthor

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

bashu commented on May 30, 2015

@bashu
OwnerAuthor

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

class form(forms.ModelForm):

    class Meta:
        widgets = {
            'address': AddressWithMapWidget({'class': 'vTextField'})
        }

}}}

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

bashu commented on May 30, 2015

@bashu
OwnerAuthor

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

bashu commented on May 30, 2015

@bashu
OwnerAuthor

Clarified readme. Fix #2.

→ <<cset 8ced16c04330>>


Original comment by: Mikhail Korobov

bashu

bashu commented on May 30, 2015

@bashu
OwnerAuthor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bashu

        Issue actions

          Select a valid choice. That choice is not one of the available choices. · Issue #22 · bashu/django-easy-maps