Issue #2 resolved

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

Ahmed Youssef
created an issue

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

Comments (5)

  1. Mikhail Korobov repo owner
    • changed status to open

    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 ( ).

    Could you please provide more details? Are you using django admin? How is your 'address' field defined?

  2. Ahmed Youssef reporter

    Yes, I'm trying to use it in the admin interface

    Well, there's a property model related as defined

    class Property(models.Model):

    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'
        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 ?


  3. Mikhail Korobov repo owner

    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.

  4. Anonymous

    but how to use it as a foreign key, what would be the approach to have it as a property to another model?

  5. Log in to comment