forked from liangliangyy/DjangoBlog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch_indexes.py
More file actions
40 lines (30 loc) · 981 Bytes
/
Copy pathsearch_indexes.py
File metadata and controls
40 lines (30 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
# encoding: utf-8
"""
@version: ??
@author: liangliangyy
@license: MIT Licence
@contact: liangliangyy@gmail.com
@site: https://www.lylinux.org/
@software: PyCharm
@file: search_indexes.py
@time: 2017/1/7 上午12:44
"""
from haystack import indexes
from django.conf import settings
from blog.models import Article, Category, Tag
class ArticleIndex(indexes.SearchIndex, indexes.Indexable):
# title = indexes.CharField(document=True, use_template=True)
text = indexes.CharField(document=True, use_template=True)
def get_model(self):
return Article
def index_queryset(self, using=None):
return self.get_model().objects.filter(status='p')
"""
class CategoryIndex(indexes.SearchIndex, indexes.Indexable):
name = indexes.CharField(document=True, use_template=True)
def get_model(self):
return Article
def index_queryset(self, using=None):
return self.get_model().objects.filter(status='p')
"""