我有haystack + django + aldryn-search設置搜索我的django-cms項目。我試圖讓我的模型上的索引工作,我可以看到結果和文字說明是好的,但網址總是/search/none
。我將如何覆蓋url定義?Django haystack,在搜索結果中沒有url
search_indexes.py:
import datetime
from haystack import indexes
from .models import Event
class EventIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
title = indexes.CharField(model_attr='title')
def get_model(self):
return Event
def index_queryset(self, using=None):
"Used when the entire index for model is updated."
return self.get_model().objects.order_by('created')
models.py
class Event(ChangesMixin, models.Model):
....
title = models.CharField(max_length=40)
....
def __str__(self):
return self.title
def get_absolute_url(self):
return '/cab/event/%i/' % self.id