Haystack: Fix error building index to a null fields

I’m using haystack on my django project using¬†Whoosh, and got some trouble once building index for the haystack and below is my haystack index definition.

class ProductIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    description = indexes.CharField(model_attr='description')

    def get_model(self):
        return Item

    def index_queryset(self, using=None):
        return self.get_model().objects.filter(created__lte=timezone.now())

And I got an error once building index using “./manage.py rebuld_index”

raise SearchFieldError("The model '%s' combined with model_attr '%s' returned None, but doesn't allow a default or null value." % (repr(obj), self.model_attr))
haystack.exceptions.SearchFieldError: The model '<Item: MyData>' combined with model_attr 'description' returned None, but doesn't allow a default or null value

Haystack has pretty good error information that “description” field not allowed to be null to be indexed on haystack. Then I fix this just add “null=True” argument following.

description = indexes.CharField(model_attr='description', null=True)

Reference: http://stackoverflow.com/a/22695639/1936697