1.相关包的安装pip install django-haystack whoosh jiebadjango-haystack:搜索框架whoosh:引擎jieba:中文分词2.setting中进行配置添加app,haystack必须在自己创建的app上面INSTALLED_APPS = [ 'django.contrib.admin', ... 'haystack', 'article_app', ]添加以下内容HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': '{ {你自己APP的名字}}.whoosh_cn_backend.WhooshEngine', 'PATH': os.path.join(BASE_DIR, 'whoosh_index'), }, }分页数HAYSTACK_SEARCH_RESULTS_PER_PAGE = 10自动刷新HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'3.在对应APP下新建一个文件文件路径:{ {你app的名字}}/search_indexes.py (不能更改)from haystack import indexes from .models import { {自己app下模型的名字}} class { {自己app下模型的名字}}Index(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) def get_model(self): return { {自己app下模型的名字}} def index_queryset(self, using=None): return self.get_model().objects.all()4.指示需要检索的字段文件路径:templates/search/in