Created
March 1, 2014 11:47
-
-
Save gauravtoshniwal1989/9288761 to your computer and use it in GitHub Desktop.
Haystack Index file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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