django-haystack
Pluggable search for Django.
What it is and what it does
Haystack is a search abstraction layer for Django that decouples your application from any specific search engine. Instead of writing search code tied to Elasticsearch or Solr, you write against Haystack's unified API and can swap backends without touching your code. It sits between your Django models and external search engines, handling indexing, querying, and result marshaling.
The package supports advanced search features like faceting, result highlighting, spelling suggestions, and spatial search. However, it is not a search engine itself—you must install and run a separate backend (Solr, Elasticsearch, Whoosh, or Xapian) and configure Haystack to connect to it. This makes it a good fit for teams that want flexibility in their search infrastructure or may need to migrate between engines later.
Use it for:
- Build a Django site with Elasticsearch search today, then switch to Solr tomorrow without rewriting search code.
- Add faceted search (filtering by category, date, price) to a Django e-commerce or content site.
- Index and search large document collections with spelling correction and result highlighting.
- Implement 'More Like This' recommendations by querying similar documents in your search backend.
- Support spatial/geographic search queries across Django models without backend-specific code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Haystack provides a unified search API for Django that lets you swap between different search backends (Solr, Elasticsearch, Whoosh, Xapian, etc.) without changing your application code.
Yes, if you are building a Django application that needs search and want the flexibility to choose or change search backends. The high install friction (requires a separate search engine and Python 3.9+, Django 4–5) is justified by the abstraction benefit. Active maintenance, no known vulnerabilities, and permissive licensing make it a safe choice. Not worth installing if you need a simple, built-in search solution or are not willing to operate a separate search service.
Install
django-haystack on PyPI
pip
pip install django-haystackuv
uv add django-haystackpoetry
poetry add django-haystackInstalling django-haystack
Before you install
High install friction: requires Django 4–5 and Python 3.9+, plus a separate search backend (Solr, Elasticsearch, Whoosh, or Xapian) to be installed and configured independently. The package itself is actively maintained with recent commits and stable status.
License in practice
BSD-3-Clause is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install django-haystack
from haystack import indexes
from haystack.query import SearchQuerySet
# Define a search index for your model
class MyModelIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
# Query via the unified API
results = SearchQuerySet().filter(content='search term')
Requires a search backend (Solr, Elasticsearch, Whoosh, or Xapian) to be installed, configured, and running separately; Haystack is an abstraction layer only.
Verify before relying
- Whether faceting, More Like This, highlighting, spatial search, and spelling suggestions are fully supported across all backends or have backend-specific limitations.
- Current state of community support and response time on the mailing list or issue tracker.
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | high — source build required |
| Runtime dependencies | 2 — Django, packaging |
| Maintenance | actively maintained — 71 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 204,948/month — #9,596 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_haystack-3.4.0.tar.gz
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
modelsearchIndexes Django models into Elasticsearch,…
permissive · top 15,000 on PyPI
farm-haystackHaystack is an end-to-end NLP framework for…
permissive · top 15,000 on PyPI
WhooshWhoosh is a pure-Python full-text search and…
permissive · top 5,000 on PyPI
Whoosh-ReloadedWhoosh-Reloaded is a pure-Python full-text…
permissive · top 15,000 on PyPI
haystack-aiHaystack is an open-source framework for…
permissive · top 5,000 on PyPI
django-elasticsearch-dsl-drfProvides Django REST framework views,…
copyleft · top 15,000 on PyPI
django-elasticsearch-dslIndexes Django model instances into…
permissive · top 15,000 on PyPI
pysolrpysolr is a lightweight Python client for…
permissive · top 15,000 on PyPI
haystack-experimentalProvides archived experimental features for…
permissive · top 15,000 on PyPI
django-tastypiedjango-tastypie provides a REST API framework…
permissive · top 15,000 on PyPI