mlavin / django-selectable

Tools and widgets for using/creating auto-complete selection widgets using Django and jQuery UI.
http://django-selectable.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
129 stars 64 forks source link

id = 0 #166

Open mandrej opened 8 years ago

mandrej commented 8 years ago

I am using AutoCompleteSelectWidget and it's working fine. Problem is when I have id = 0 (legacy data base), widget doesn't populate this field and matching field is empty string. Autosugest is working. Please help

mlavin commented 8 years ago

If I had to venture a guess it's this conditional in the decompress which is seeing the 0 and not populating the value: https://github.com/mlavin/django-selectable/blob/master/selectable/forms/widgets.py#L70

mandrej commented 8 years ago

Thank you for your help. I changed:

/selectable/forms/widgets.py

def decompress(self, value): if value is not None: ...

and:

/selectable/base.py

class ModelLookup(LookupBase): def get_item(self, value): item = None if value is not None: ...

On Wed, May 18, 2016 at 2:45 PM, Mark Lavin notifications@github.com wrote:

If I had to venture a guess it's this conditional in the decompress which is seeing the 0 and not populating the value: https://github.com/mlavin/django-selectable/blob/master/selectable/forms/widgets.py#L70

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/mlavin/django-selectable/issues/166#issuecomment-220014748