Skip to content

Instantly share code, notes, and snippets.

@abhinavsingh
Created June 5, 2012 19:34
Show Gist options
  • Save abhinavsingh/2877237 to your computer and use it in GitHub Desktop.
Save abhinavsingh/2877237 to your computer and use it in GitHub Desktop.
haystack events module search index
import datetime
from haystack import indexes
from events.models import *
class EventIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
location = indexes.LocationField(model_attr='get_location')
def get_model(self):
return Event
def index_queryset(self):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(created_on__lte=datetime.datetime.now())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment