MrDoc/app_doc/search_indexes.py

20 lines
584 B
Python
Raw Normal View History

2020-11-26 20:55:44 +08:00
# coding:utf-8
# @文件: search_indexes.py
# @创建者:州的先生
# #日期2020/11/22
# 博客地址zmister.com
from haystack import indexes
from app_doc.models import *
# 文档索引
class DocIndex(indexes.SearchIndex,indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
top_doc = indexes.IntegerField(model_attr='top_doc')
modify_time = indexes.DateTimeField(model_attr='modify_time')
def get_model(self):
return Doc
def index_queryset(self, using=None):
return self.get_model().objects.filter(status=1)