Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python haystack搜索开始于_Python_Django_Django Haystack - Fatal编程技术网

Python haystack搜索开始于

Python haystack搜索开始于,python,django,django-haystack,Python,Django,Django Haystack,为什么我使用: users = SearchQuerySet().all() users = users.filter(name__startswith='foo') 我对结果有疑问。当我使用 users = SearchQuerySet().models(UserProfile) users = users.filter(name__startswith='foo') 我有一个空问题 Thx:)从您所有的模型中,您在哪个模型中创建了搜索索引?您是否有UserProfile的SearchIn

为什么我使用:

users = SearchQuerySet().all()
users = users.filter(name__startswith='foo')
我对结果有疑问。当我使用

users = SearchQuerySet().models(UserProfile)
users = users.filter(name__startswith='foo')
我有一个空问题


Thx:)

从您所有的模型中,您在哪个模型中创建了
搜索索引?您是否有
UserProfile
SearchIndex
,类似于:

from haystack import indexes
from haystack import site


class UserProfileIndex(indexes.SearchIndex):
    ...

site.register(UserProfile, UserProfileIndex)

您只能看到已编制索引的模型。从您发布的代码来看,您似乎没有索引
UserProfile
,而是索引了一些其他模型。

您的第一次查询返回了哪些模型?