Filtering Django-haystack results using attributes?

Can someone show me an example of how to filter full-text search results using django-haystack using attributes? I looked through the tutorial on my website but am still sure how to use the haystack.

For example, let's say I have a class Product:

class Product(models.Model):
    title = models.CharField(max_length=200)
    description = models.TextField()
    category = models.CharField(max_length=10)
    color = models.CharField(max_length=10)

If I want to provide full-text search by name and description, and filtering (based on drop-down lists, not free text) by category and color - what should I do? Can I use forms and views that come with a stack of hay?

Thank.

+3
source share
2 answers

/ - django-haystack? Note, .

, haystack search, - django-filter Alex Gaynor, , . , django-haystack. . doc , .

+6

, ,

  • .
 title =  CharField(model_attr='title', faceted=True)
 description =  CharField(model_attr='description', faceted=True)
  sqs = SearchQuerySet().facet('title').facet('description')
  • , haystack urls.py,
  url(r'^$', FacetedSearchView(form_class=FacetedSearchForm, searchqueryset=sqs), name='haystack_search'),
 
   python manage.py rebuild_index
+1

Source: https://habr.com/ru/post/1726500/


All Articles