modlinltd/django-advanced-filters

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

PeterTillema opened this issue · 2 comments

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:

if formdata['operator'] == "isnull":
return {key: None}

+1

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

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