Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bashu opened this issue May 30, 2015 · 3 comments
Closed

Comments

@bashu
Copy link
Owner

bashu commented May 30, 2015

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


@bashu bashu closed this as completed May 30, 2015
@bashu
Copy link
Owner Author

bashu commented 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
Copy link
Owner Author

bashu commented 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

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
Copy link
Owner Author

bashu commented 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant