开发者

Django haystack search returning items that are excluded

开发者 https://www.devze.com 2023-03-04 20:48 出处:网络
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

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, mo开发者_运维百科del_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 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

0

精彩评论

暂无评论...
验证码 换一张
取 消