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

v2 upgrading instructions incomplete. #229

Closed
spookylukey opened this issue Jan 6, 2014 · 6 comments
Closed

v2 upgrading instructions incomplete. #229

spookylukey opened this issue Jan 6, 2014 · 6 comments

Comments

@spookylukey
Copy link
Contributor

I'm upgrading from v1.4.7, and tried the upgrade instructions. There is a missing step for ModelForm autocomplete.

autocomplete_light.register() signature has changed - you now need to provide the model as first parameter, at least it you want the autocomplete_light.ModelForm method to work.

For the case of providing multiple autocomplete classes for the same product, the docs seem inadequate too, in the section "Registering the same Autocomplete class for several autocompletes"

It shows how to register more than one, but not how to use them. It seems like for an autocomplete_light.ModelForm, it just uses the last one. It seems like the easiest way is to use autocomplete_light.ChoiceField or MultipleChoiceField

@jpic
Copy link
Member

jpic commented Jan 6, 2014

autocomplete_light.register() signature has changed - you now need to provide the model as first parameter, at least it you want the autocomplete_light.ModelForm method to work.

It has not changed to my knowledge:

  • If you don't specify a model then it will register it as "generic" autocomplete and be used by generic fields by default.
  • If you do specify a model then it will register it as the default autocomplete for that model.

If registering several autocompletes for the same model, it is required to specify the channel names manually:

# at registration
autocomplete_light.register(YourAutocomplete, YourModel, name='FirstAutocomplete')
autocomplete_light.register(YourAutocomplete, YourModel, name='SecondAutocomplete')

# In the modelform
class YourModelForm(autocomplete_light.ModelForm):
    first_autocomplete = autocomplete_light.ModelChoiceField('FirstAutocomplete')
    second_autocomplete = autocomplete_light.ModelChoiceField('SecondAutocomplete')

    # ....

Which has some dry breaking implications, which is why I have planned to support something like this for 2.0 final:

class YourModelForm(autocomplete_light.ModelForm):
    class Meta:
        autocomplete_channels = {
            'first_autocomplete': 'FirstAutocomplete',
            'second_autocomplete': 'SecondAutocomplete',
        }

Suggestions are welcome !

Also, thanks a lot for your feedback, I will study it in detail and see how the docs can be improved.

@spookylukey
Copy link
Contributor Author

OK, it might not have changed, but the upgrading docs are slightly misleading. Because I was using an autocomplete widget before, I had registered my autocomplete without specifying the model. This works fine if you specify the exact autocomplete class to use, but switching to the autocomplete_light.ModelForm didn't work.

Perhaps an alternative upgrade route should be added, indicating autocomplete_light.ModelChoiceField or ModelMultipleChoiceField, which worked well for me.

@jpic
Copy link
Member

jpic commented Jan 6, 2014

Yep, I understand what you mean, I just don't have time to update docs right now so please leave this issue open in the mean time.

If you have any further question I will find time to answer though.

@jpic
Copy link
Member

jpic commented Jan 15, 2014

Not over yet but some work has been done in b47422d

@jpic
Copy link
Member

jpic commented Jan 21, 2014

I've updated the upgrade docs, please let me know if I missed anything.

Thanks a heap for your feedback.

@jpic
Copy link
Member

jpic commented Jan 21, 2014

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

2 participants