django-advanced-filters icon indicating copy to clipboard operation
django-advanced-filters copied to clipboard

Is NULL should have value "True", not "None"

Open PeterTillema opened this issue 5 years ago • 2 comments
trafficstars

Describe the bug If you have a field which should be null, i.e. type "Is NULL", no matter what you select as the key (which should be something, it can't empty, huh?), the key gets replaced with "null" which translates to Python with "None", rather than "true", which becomes "True" in Django, and that is what we want.

See https://docs.djangoproject.com/en/3.0/ref/models/querysets/#isnull for more information.

I think this is the issue: https://github.com/modlinltd/django-advanced-filters/blob/90a8ed57571b8124fb7139969eecc1138922e8a3/advanced_filters/forms.py#L94-L95

PeterTillema avatar May 27 '20 13:05 PeterTillema

+1

When I use "isnull" lookup on foreign field, I get Cannot use None as a query value. It should be True instead.

eriktelepovsky avatar Dec 20 '21 14:12 eriktelepovsky

@PeterTillema your fix is not enough but thank you for pointing me. I created PR which solves the issue correctly: #156

eriktelepovsky avatar Dec 20 '21 15:12 eriktelepovsky