Created
January 31, 2016 17:07
-
-
Save nitely/3a39d6eb6dd0196ff9ae to your computer and use it in GitHub Desktop.
Haystack extend index
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
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.apps import AppConfig | |
class ChildAppConfig(AppConfig): | |
name = 'child_app' | |
verbose_name = "child app" | |
label = 'child_app' | |
def ready(self): | |
from main_app.search_hooks import MainAppSearchHook | |
from .search import ChildAppIndex | |
MainAppSearchHook.register(ChildAppIndex) |
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
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from haystack import indexes | |
class ChildAppIndex(object): | |
body = indexes.CharField(model_attr='body') |
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
from hooks.haystackhook import HaystackHook | |
MainAppSearchHook = HaystackHook() |
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
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from haystack import indexes | |
from .models import MainApp | |
from .search_hooks import MainAppSearchHook | |
class MainAppIndexBase(indexes.SearchIndex): | |
text = indexes.CharField(document=True, use_template=True) | |
title = indexes.CharField(model_attr='title') | |
def get_model(self): | |
return MainApp | |
MainAppIndex = MainAppSearchHook.build_search_index(MainAppIndexBase) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment