Django haystack 搜索返回被排除的项目

发布于 2024-11-07 03:24:43 字数 1261 浏览 0 评论 0原文

我在 django-haystack 方面遇到了一些问题,需要一些帮助。

我运行一个对项目进行索引的网站,某些项目处于不应该被看到的状态,即 status='DE'status='PR'

我当前的设置是。

from haystack.indexes import *
from haystack import site
from models import Project

class ProjectIndex(RealTimeSearchIndex):
    project_name = CharField(document=True, use_template=True)
    description = CharField(use_template=True, model_attr='description')
    location = CharField(use_template=True, model_attr='location')
    owner = CharField(model_attr='owner')

    def search(self):
        return Project.objects.filter(status='AP').exclude(status='PR').exclude(status='DE')

    def index_queryset(self):
        """Used when the entire index for model is updated."""
        return Project.objects.filter(status='AP').exclude(status='PR').exclude(status='DE')

    def get_queryset(self):
        """Used when the entire index for model is updated."""
        return Project.objects.filter(status='AP').exclude(status='PR').exclude(status='DE')

    def read_queryset(self):
        """Used when the entire index for model is updated."""
        return Project.objects.filter(status='AP').exclude(status='PR').exclude(status='DE')

site.register(Project, ProjectIndex)

I have been having some issues with django-haystack and need some help.

I run a site that indexes projects and certain projects are in a status where they should not be seen, ie status='DE', status='PR'

my current setup is.

from haystack.indexes import *
from haystack import site
from models import Project

class ProjectIndex(RealTimeSearchIndex):
    project_name = CharField(document=True, use_template=True)
    description = CharField(use_template=True, model_attr='description')
    location = CharField(use_template=True, model_attr='location')
    owner = CharField(model_attr='owner')

    def search(self):
        return Project.objects.filter(status='AP').exclude(status='PR').exclude(status='DE')

    def index_queryset(self):
        """Used when the entire index for model is updated."""
        return Project.objects.filter(status='AP').exclude(status='PR').exclude(status='DE')

    def get_queryset(self):
        """Used when the entire index for model is updated."""
        return Project.objects.filter(status='AP').exclude(status='PR').exclude(status='DE')

    def read_queryset(self):
        """Used when the entire index for model is updated."""
        return Project.objects.filter(status='AP').exclude(status='PR').exclude(status='DE')

site.register(Project, ProjectIndex)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你列表最软的妹 2024-11-14 03:24:43

我设法通过从 1.1 更新到 1.2 来解决这个问题

,然后突然我开始收到这些 Caught VariableDoesNotExist while rendering: Failed Lookup for key [object] in u'None'

Google 了一下并发现了某些项目可能已从系统中消失,并且有一个方便的命令可以实现这一点。

现在我有一个 cronjob 每隔几个小时执行以下 /usr/bin/python2.6 /www/mysite/manage.py update_index --remove

I managed to solve this issue by updating from 1.1 to 1.2

then all of the sudden I started receiving these Caught VariableDoesNotExist while rendering: Failed lookup for key [object] in u'None'

Googled it and found out that certain items might have disappeared out of the system and there is a handy command for that.

now I have a cronjob that does the following /usr/bin/python2.6 /www/mysite/manage.py update_index --remove every few hours

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文