我下面就haystack documentation.Django的草垛不會指數我的數據
說明我沒有得到任何結果SearchQuerySet()。所有()。
我認爲這個問題是在這裏
$ ./manage.py rebuild_index
WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y
Removing all documents from your index because you said so.
All documents removed.
Indexing 0 notes. // <-- here 0 notes!
的mysite/NOTE/search_indexes.py看起來像
import datetime
import haystack
from haystack import indexes
from note.models import Note
class NoteIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
author = indexes.CharField(model_attr='user')
pub_date = indexes.DateTimeField(model_attr='pub_date')
def get_model(self):
return Note
def index_queryset(self):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(pub_date__lte=datetime.datetime.now())
和我的mysite/NOTE /模板/搜索/索引/ NOTE/Note_text。 TXT
{{ object.title }}
{{ object.user.get_full_name }}
{{ object.body }}
您是否擁有運行haystack.autodiscover的search_sites.py?
你註冊過主haystack.site(通常在您的search_indexes.py中的 )模型嗎?
但在第一篇文章中沒有提到search_sites.py,haystack.autodiscover,haystack.site。
我很困惑。他們的文檔是否涉及不同的乾草堆版本?
我的設置是..
草垛版本2.0.0.beta
的Django 1.3.1
的Solr 3.6.0
sqlite的3
在我的(愚蠢的)情況下,rebuild_index沒有索引任何產品,因爲沒有任何(db連接是不正確的)。 – 2018-03-07 13:44:42