5
votes

I have a puzzle, my haystack+whoosh works just fine:) I can search through f.e. name of the content. BUT I want to add "taggit" to my core-model and search through tags then I have NO results:// and I don't know why. More precisely I know that content name "X" has a tag "foo" and when I make search through "foo" I have no result:/

Taggit is a simple tag module for django. Here is the part of my search_indexes.py file:

import datetime
from haystack.indexes import *
from haystack import site
from models import Skill

class SkillIndex(SearchIndex):
   text = CharField(document = True, use_template = True)
   tags = CharField(model_attr='tags')

site.register(Skill, SkillIndex) 

Best regards, nykon

PS My target is to make live-search like google by use of tags. Does someone has a good idea?

1

1 Answers

3
votes

You can add the tags to the data template,

For example:

{{ object.name }}
{% for tag in object.tags.all %}{{ tag.name }} {% endfor %}

Not sure that this is the best solution, but it works.