PHACDataHub / django-htmx-autocomplete

A Django autocomplete component powered by htmx
MIT License
50 stars 4 forks source link

ValueError if `HTMXAutoComplete.get_items` values is empty string #53

Open H4rryK4ne opened 10 months ago

H4rryK4ne commented 10 months ago

Hi,

I played around with your example.

I created a view:

# my_app/view.py
from autocomplete import widgets
from django.shortcuts import render

# class MultipleFormModel ...

def index(request):
    form = MultipleFormModel(request.GET)
    return render(request, "base.html", {"form": form})

If I call the with http://localhost:8000/?name=Foo&members= (empty member list) I get an unexpected exception. If I create the ModelForm without the AutoComplete widget I only get the error message that "" is not a valid value.

It seems to me, that it is not sufficient to check if values is not None