django-autocomplete-light modelform ValidationError

385 Views Asked by At

I have an autocomplete fields in 2 diferent forms.

One is with forms.Form and works ok.

Other one is with ModelForm and this doesn't work

If I try with:

class FacturaForm(ModelForm):
    class Meta:
        widgets = autocomplete_light.get_widgets_dict(Factura)
        model = Factura

throws:

ValidationError at /facturas/nuevo/1/

[u'type cannot validate [0]']

.... {{ form.as_table }} ....


If I try with:

class FacturaForm(ModelForm):
    class Meta:
        model = Factura
        widgets = {
            'cliente': autocomplete_light.ChoiceWidget('ClienteAutocomplete'),
        }

throws:

ValidationError at /facturas/nuevo/1/

[u'ClienteAutocomplete cannot validate [0]']


and if I try with:

class FacturaForm(ModelForm):

    cliente = autocomplete_light.GenericModelChoiceField(
        widget=autocomplete_light.ChoiceWidget(
            autocomplete='ClienteAutocomplete',
            autocomplete_js_attributes={'minimum_characters': 0, }))

    class Meta:
        model = Factura

the autocomplete works fine and seems all to work well, but if I send form to save throws:

ValueError at /facturas/nuevo/1/

need more than 1 value to unpack

.... if form.is_valid(): ....


Any idea what might be wrong?

Thanks for help

0

There are 0 best solutions below