Skip to content

Instantly share code, notes, and snippets.

@gauravtoshniwal1989
Created March 1, 2014 11:47
Show Gist options
  • Save gauravtoshniwal1989/9288761 to your computer and use it in GitHub Desktop.
Save gauravtoshniwal1989/9288761 to your computer and use it in GitHub Desktop.
Haystack Index file
class CompanyIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
name = indexes.CharField(model_attr='name')
owner = indexes.CharField()
def get_model(self):
return Company
def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.all()
def prepare_owner(self,obj):
return obj.user.first_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment