Skip to content

Instantly share code, notes, and snippets.

@valyagolev
Created May 4, 2011 05:24
Show Gist options
  • Save valyagolev/954797 to your computer and use it in GitHub Desktop.
Save valyagolev/954797 to your computer and use it in GitHub Desktop.
django-haystack is annoying
from search_sites import register_model_for_search
from .models import CoolModel
register_model_for_search(CoolModel)
from search_sites import register_model_for_search, BaseIndex, indexes
from .models import ComplicatedModel
class ComplicatedIndex(BaseIndex):
author = CharField(model_attr='user')
register_model_for_search(ComplicatedModel, ComplicatedIndex)
from haystack import indexes, autodiscover, site
class BaseIndex(indexes.SearchIndex):
text = indexes.CharField(document=True, use_template=True)
def register_model_for_search(model, index=BaseIndex):
site.register(model, index)
autodiscover()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment