Skip to content
Haystack for Django REST Framework
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Updated docs with new release May 21, 2019
drf_haystack Merge remote-tracking branch 'origin/master' May 21, 2019
tests
.dockerignore Symlinked .gitignore to .dockerignore Jan 6, 2018
.gitignore Replaced requirements.txt with Pipfile Aug 14, 2018
.travis.yml Merge remote-tracking branch 'origin/master' May 21, 2019
Dockerfile Dockerfile for development Jan 6, 2018
LICENSE.txt fixed LICENSE file and added Michael Fladischer to contributions for … Aug 31, 2015
MANIFEST.in Replaced requirements.txt with Pipfile Aug 14, 2018
Pipfile
README.md let there be colour (#137) May 9, 2019
docker-compose.yml Sorting WIP Jun 16, 2018
ez_setup.py initial commit Feb 12, 2015
manage.py moved manage.py out of tests package Feb 13, 2015
setup.cfg Updated settings.cfg and requirements.txt Jan 6, 2018
setup.py Updated package requirements May 21, 2019
tox.ini Merge remote-tracking branch 'origin/master' May 21, 2019

README.md

Haystack for Django REST Framework

Build status

Build Status Coverage Status PyPI version Documentation Status

About

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

Supported versions

  • Python 2.7, 3.4 and above
  • Django 1.11 and 2.0-2.2
  • Haystack 2.8 and above
  • Django REST Framework 3.7 and above

Installation

$ 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)

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

# ViewSet
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!

You can’t perform that action at this time.