You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking at this more. The error does get thrown when lookup_expr='isnull' but I think I was missing the point. I think this is more of a documentation issue. I assumed when reading the documentation that I needed to set lookup_expr='isnull' when I wanted to add a Null lookup to a ModelChoiceField. I finally understand that is not the case. I just need to add a null_label='NULL' which add the null value to the ModelChoiceField.
That is not clear in the documentation. The filter works as expected (able to find empty fields) if I just set that value.
When using the ModelChoiceFilter with an lookup_expr='isnull' django throws a value error exception
Cannot use None as a query value
This is caused by the ChoiceFilter.filter function that uses "None" instead of "True" as the value.
Line 169 in the filters.py module:
qs = self.get_method(qs)(**{'%s__%s' % (self.field_name, self.lookup_expr): None})
The ModelChoiceFilter should have it's own filter function defined as follows:
The text was updated successfully, but these errors were encountered: