This is driving me a bit mad but seems like it should be simple.
I'm using Django and Haystack and have a search index including an IntegerField which allows null. This is based on a related model in Django, but I don't think this matters. eg:
class ThingIndex(indexes.ModelSearchIndex, indexes.Indexable):
group = indexes.IntegerField(model_attr='group__id', null=True)
class Meta:
model = Thing
I sometimes want my Haystack query to return items with None/Null for this field, so I'm filtering in the search form's __init__, but I can't get a query to do this. The most obvious way I tried was:
self.searchqueryset.filter(group__isnull=True) # how to do it on a regular Django queryset
But this returns no records.
Right now I'm working around it with this:
self.searchqueryset.exclude(group__in=range(1,100))
Which works, but obviously isn't the way it should be done :)
Can anyone help?
Thanks!