Iterating over items in a search result view with Django haystack MultiValueField Iterating over items in a search result view with Django haystack MultiValueField django django

Iterating over items in a search result view with Django haystack MultiValueField


The actual issue is that the M2M field is not indexed in SearchEngine. You should return primitive objects( list, string, int, etc.) in the prepare_ function and not Django Moldel instances.

e.g.

def prepare_attr(self, obj):   return [str(v) for v in obj.attrs.all()]