skillfed

django-haystack

Pluggable search for Django.

django-haystack v3.4.0 204.9K downloads/30d#9,596 on PyPI3,739
Permissive license BSD-3-Clause Active released

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-haystack

uv

uv add django-haystack

poetry

poetry add django-haystack

Installing 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

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.1Framework :: Django :: 5.2Intended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Free ThreadingTopic :: Utilities

Tags

django search abstraction layerpluggable search backends djangoelasticsearch solr whoosh djangounified search api djangofaceted search djangodjango search indexing
search-abstractiondjango-integration

More Utilities packages