I used django to build a website, in which there are multiple rich text field, in a model. I use django-haystack to do a site-wide search, but only the entire model instance is returned. How do I know which field has been found in this model instance?
the following is my code
-sharpmodels.py
class Version(models.Model):
name=models.CharField("",max_length=25)
user = models.ForeignKey(User,on_delete=models.CASCADE,verbose_name="")
update_description = RichTextUploadingField("")
description=RichTextUploadingField("")
publish_date = models.DateTimeField("",auto_now_add=True)
reports=RichTextUploadingField("")
scripts=RichTextUploadingField("")
-sharpsearch_indexs.py
class VersionIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
def get_model(self):
return Version
def index_queryset(self, using=None):
return self.get_model().objects.all()
-sharpversion_text.txt
{{ object.name }}
{{ object.update_description }}
{{ object.description }}
{{ object.reports }}
{{ object.scripts }}