-
Notifications
You must be signed in to change notification settings - Fork 466
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
error when using autocomplete_light.ChoiceField #410
Comments
What versions ? (Django, Python, OS, Browser) Maybe Django is passing unicode and it can't compare with items which are in your str list. |
My django version is 1.5.2, python 2.7.5, mac os, firefox browser. |
I think that the problem is that the way you do would require overriding choices_for_values(). So choices_for_values will use Maybe it would be easier for you to make a choices dynamic property with |
I think you haven't got my point. |
On Wed, May 13, 2015 at 4:44 AM, zhiyajun11 notifications@github.com
http://django-autocomplete-light.readthedocs.org/en/stable-2.x.x/api.html#autocomplete_light.autocomplete.base.AutocompleteInterface.validate_values As I said, that:
Is wrong, because obviously http://django-autocomplete-light.readthedocs.org/en/stable-2.x.x/api.html#autocompleteinterface If you want to continue breaking the pattern it was designed for, override choices in validation too, and that's Else, maybe set self.choices in constructor or make it a dynamic property. http://yourlabs.org http://blog.yourlabs.org |
That's not how it works. You can't set some instance variable in one request (ajax GET request), and then expect it to still be there in another request (form POST submit). Hopefully Django and autocomplete-light are both thread safe. |
The above code, which is the method of FieldBase of autocomplete-light, shows that it failed at |
Nice catch !
There's even a docstring issue there because it doesn't mention the super
call.
It would probably have been better in the beginning to pass the field
instance to the autocomplete instance in that code and let
`Autocomplete.validate_values()` call `field.validate(value)`. It's a bit
a harsh BC break but might be a good idea for v3.
A perhaps simple way would be to add a field attribute, ie.
ChoiceField('FooAutocomplete', skip_field_validation=True).
What do you think ?
|
I think that fix works, but I can't release it without making a proper security audit. |
That's will be fine. But it's not an easy job based on current structure. Hoping for v3 and autocomplete-light is really a nice project. Good luck. |
Closing in favor of PR #416 which should be in the next release. Thanks again for your feedback ! |
Could you try with 2.2.0rc1 which was released yesterday ? Thanks. |
The backend seems to go well. But there is a js error in the front-end, which result in the disappearing of prompt box. The error is:
My browser is firefox. |
My autocomplete is :
Form is :
View is :
However, when I post the resquest with 'dae' as the profession, 'f.is_valid()' failed saying that 'dae' is not a valid choice. What the matter?
The text was updated successfully, but these errors were encountered: