Skip to main content

drf-query-method

PyPI version

Support for the HTTP QUERY method (RFC 10008) in Django REST framework.

QUERY is safe and idempotent like GET, but carries a request body like POST. It suits searches whose parameters are too long or too structured for a URL.

Usage

Define a query() handler, then call patch() once at startup:

import drf_query_method

drf_query_method.patch()


class NoteViewSet(ModelViewSet):
    ...

    def query(self, request, *args, **kwargs):
        return self.list(request, *args, **kwargs)

Routers then send QUERY /notes/ to query(), and SearchFilter, OrderingFilter, django-filter's DjangoFilterBackend and django-rest-framework-datatables read their parameters from the request body. If you'd rather not patch DRF, import drop-in classes with the same names from drf_query_method instead. See the documentation for both approaches, and for sending QUERY requests from JavaScript and other clients.

The package is in early development. Releases are on PyPI.

CSRF

QUERY is a safe method, so it never needs a CSRF token, on any supported Django version. Django 6.2 exempts it from CSRF checks itself. On Django 4.2 to 6.1, where this package adds QUERY, it also teaches Django's CsrfViewMiddleware to treat QUERY as safe, so the behaviour matches 6.2. DRF's SessionAuthentication uses the same check, so session-authenticated QUERY requests work without a token too.

The trade-off is the one GET has always had: a query() handler must never change data. Cross-site requests are still guarded by CORS, because browsers can only send QUERY from JavaScript, and QUERY isn't a CORS-safelisted method, so a cross-origin request needs your server's permission first.

Compatibility

  • Python 3.10+
  • Django 4.2, 5.0, 5.1, 5.2, 6.0 and 6.1. Django 6.2 adds QUERY natively; on earlier versions this package adds it, including Django 6.2's CSRF behaviour.
  • Django REST framework 3.16+
  • django-filter and django-rest-framework-datatables, optionally

Installation

pip install drf-query-method

Contributing

See CONTRIBUTING.md for development setup, testing, and release instructions.

Metadata

Release files for drf-query-method 0.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-query-method 0.3.0
File Size Uploaded Provenance Actions
drf_query_method-0.3.0.tar.gz 104.2 kB With provenance Details for drf_query_method-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for drf-query-method 0.3.0
File Interpreter ABI Platform Actions
drf_query_method-0.3.0-py3-none-any.whl Python 3 none any Details for drf_query_method-0.3.0-py3-none-any.whl

Total release size: 117.3 kB

Release files / drf_query_method-0.3.0.tar.gz

Download URL drf_query_method-0.3.0.tar.gz
Size 104.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b629ca2fbd521a8108715d578e08a59a0ea71e0a66f4643092d9d5b4fa1e091d
BLAKE2b-256 checksum
How to use checksums
ad3399ed25a55ac05d3cef63739ef9d217cff8f7efe2bc721b3efb29f259ae02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / drf_query_method-0.3.0-py3-none-any.whl

Download URL drf_query_method-0.3.0-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fad5a2ab2f8f21837cbf689c0d5ec42487acbc3d6b9d38c901b32a9711259066
BLAKE2b-256 checksum
How to use checksums
13ff709d9ad89542e293189bfc6c7df9bce816ec8a0bc8eba3115889edbc8a4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for drf-query-method 0.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for drf_query_method-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

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