﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37522	"Class-based views with a `query` attribute crash on QUERY requests since ""query"" was added to View.http_method_names"	Mariano Ignacio Baragiola	Mariano Ignacio Baragiola	"5c13b5a198 (#37232) added `""query""` to `View.http_method_names`. `View` treats any attribute whose name is in that list as a handler (`dispatch()`, `view_is_async`, `_allowed_methods()`), and `query` is a common name for an attribute on a search view. Such views now break:

{{{#!python
from django.http import HttpResponse
from django.views import View


class SearchView(View):
    query = """"

    def get(self, request):
        return HttpResponse(self.query)
}}}

 * A `QUERY` request to `SearchView` raises `TypeError: 'str' object is not callable` (HTTP 500). On 6.1 it returns 405.
 * An `OPTIONS` request (or a 405 response) lists `QUERY` in the `Allow` header.
 * With `query = None` and an `async def get()`, `view_is_async` raises `ImproperlyConfigured: ... HTTP handlers must either be all sync or all async.` when `as_view()` runs, so the URLconf fails to import and the project does not start.

Two more cases follow from the same change but can't be fixed without undoing it:

 * A helper method or `@cached_property` named `query` (for example `def query(self)` returning a queryset) now runs for `QUERY` requests and fails with `TypeError` (500).
 * `SearchView.as_view(query=""x"")` now raises `TypeError: The method name query is not accepted as a keyword argument to SearchView().`

The 6.2 release notes list QUERY support only under ""What's new"", not under backwards incompatible changes.

Versions affected: main only (not in stable/6.1.x). Regression in 5c13b5a198.

Suggested fix: treat a method name as handled only when the attribute is callable, in `dispatch()`, `view_is_async`, and `_allowed_methods()`. Views with a non-callable `query` attribute then behave as in 6.1. Add a note to the 6.2 backwards incompatible changes for the two cases above (a `query()` method written for another purpose, and `as_view(query=...)`). Patch: PR to follow.

AI disclosure: I found and reproduced this with Claude Code (Anthropic)."	Cleanup/optimization	assigned	Documentation	dev	Normal				Accepted	0	0	0	0	0	0
