by rhblind

rhblind / drf-haystack

Haystack for Django REST Framework

216 Stars 50 Forks Last release: Not found MIT License 490 Commits 26 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Haystack for Django REST Framework

Build status

Build Status Coverage Status PyPI version Documentation Status


Small library which tries to simplify integration of Haystack with Django REST Framework. Fresh documentation available on Read the docs!

Supported versions

  • Python 3.5 and above
  • Django 2.2 and 3.0
  • Haystack 2.8 and above
  • Django REST Framework 3.7 and above


$ pip install drf-haystack

Supported features

We aim to support most features Haystack does (or at least those which can be used in a REST API). Currently we support:

  • Autocomplete
  • Boost (Experimental)
  • Faceting
  • Geo Spatial Search
  • Highlighting
  • More Like This

Show me more!

from drf_haystack.serializers import HaystackSerializer
from drf_haystack.viewsets import HaystackViewSet

from myapp.search_indexes import PersonIndex # BYOI™ (Bring Your Own Index)


class PersonSearchSerializer(HaystackSerializer): class Meta: index_classes = [PersonIndex] fields = ["firstname", "lastname", "full_name"]


class PersonSearchViewSet(HaystackViewSet): index_models = [Person] serializer_class = PersonSerializer

That's it, you're good to go. Hook it up to a DRF router and happy searching!

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.