Jump to >


class BaseSearchIndex[source]

Bases: haystack.indexes.SearchIndex

Base class for a search index.

This sets up a few common fields we want all indexes to include.

model = None[source]

The model to index.

local_site_attr = None[source]

The local site attribute on the model.

For ForeignKeys, this should be the name of the ID field, as in ‘local_site_id’. For ManyToManyFields, it should be the standard field name.

text = <haystack.fields.CharField object>[source]
local_sites = <haystack.fields.MultiValueField object>[source]
NO_LOCAL_SITE_ID = 0[source]

Return the model for this index.


Prepare the list of local sites for the search index.

This will take any associated local sites on the object and store them in the index as a list. The search view can then easily look up values in the list, regardless of the type of object.

If the object is not a part of a local site, the list will be [0], indicating no local site.

fields = {'local_sites': <haystack.fields.MultiValueField object>, 'text': <haystack.fields.CharField object>}
objects = <haystack.manager.SearchIndexManager object>