一切正常,但我的127.0.0.1:8000为什么什么都不显示?我用了django-sphinx

0 投票
1 回答
588 浏览
提问于 2025-04-15 18:55
from djangosphinx.models import SphinxSearch
def xx(request):
    queryset =File.search.query('test')
    #return HttpResponse(queryset)#<------1
    return render_to_response('a.html',{'a':queryset})#<--------2

class File(models.Model):
    name = models.CharField(max_length=200)
    tags = models.CharField(max_length=200) # We actually store tags for efficiency in tag,tag,tag format here

    objects = models.Manager()
    search  = SphinxSearch(index="test1")

a.html:

{% for i in a %}
    Some value: {{i}}
{% endfor %}

1 个回答

0

因为你没有提供很多信息,我只能做个有根据的猜测。你可能没有建立搜索索引。在查询之前,先试着建立一下索引,Sphinx搜索的是索引,而不是数据库。

撰写回答