Created
May 4, 2011 05:24
-
-
Save valyagolev/954797 to your computer and use it in GitHub Desktop.
django-haystack is annoying
This file contains hidden or 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
from search_sites import register_model_for_search | |
from .models import CoolModel | |
register_model_for_search(CoolModel) |
This file contains hidden or 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
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) |
This file contains hidden or 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
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