Skip to main content

drf-haystack-search-filter

A django-haystack search filter for Django Rest Framework.

This package uses uv for project management. To get started, ensure that uv is installed on your machine and updated to the 0.5.6 version. Detailed installation instructions for uv can be found here.

Installation

uv add drf-haystack-search-filter

Usage

Simply import the HaystackSearchFilter and use it in your API views:

from drf_haystack_search_filter.filters import HaystackSearchFilter

...

class MyAPIView(...):
    ...
    filter_backends = [HaystackSearchFilter, ...]
    ...

You can customize the search behavior by overriding the _search method.

from typing import TypeVar

from drf_haystack_search_filter import HaystackSearchFilter

T = TypeVar("T")


class MyHaystackSearchFilter(HaystackSearchFilter):
    def _search(self, request: Request, queryset: QuerySet[T], view: APIView, query: str) -> QuerySet[T]:
        # Customize the search behavior here
        return queryset.filter(
            pk__in=(
                SearchQuerySet()
                .models(queryset.model)
                .filter(content__startswith=query)
                .values_list("pk", flat=True)
            )
        )

class MyAPIView(...):
    ...
    filter_backends = [MyHaystackSearchFilter, ...]
    ...

Development

uv sync --frozen --group=development
uv run --frozen pre-commit install --install-hooks
uv run --frozen pre-commit install --hook-type=commit-msg

Contributing

Contributions are welcome! To get started, please refer to our contribution guidelines.

Issues

If you encounter any problems while using this package, please open a new issue here.

Metadata

Release files for drf-haystack-search-filter 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for drf-haystack-search-filter 1.3.0
File Size Uploaded Provenance Actions
drf_haystack_search_filter-1.3.0.tar.gz 12.6 kB Without provenance Details for drf_haystack_search_filter-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for drf-haystack-search-filter 1.3.0
File Interpreter ABI Platform Actions
drf_haystack_search_filter-1.3.0-py3-none-any.whl Python 3 none any Details for drf_haystack_search_filter-1.3.0-py3-none-any.whl

Total release size: 16.5 kB

Release files / drf_haystack_search_filter-1.3.0.tar.gz

Download URL drf_haystack_search_filter-1.3.0.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9e99e436c9ad08f65f63815864995b5408bded280aa6951b5e4c098269c94d2d
BLAKE2b-256 checksum
How to use checksums
a8510e3824d32ec58aef7a4d5508f128d7c8cbe7ddfb812d96d46ca1fd4225df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.6

Release files / drf_haystack_search_filter-1.3.0-py3-none-any.whl

Download URL drf_haystack_search_filter-1.3.0-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
76a182660750f2ae8b01ce5ea8cb1303e661f7360c851044380e8d7db14a0f26
BLAKE2b-256 checksum
How to use checksums
7a4d7edac38b64e1c6af96fa4f4eda298a36ed9edca18359a449b24bad0bb981
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.6

Security for drf-haystack-search-filter 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page