From 3ca6c60636005b82a53f0f98f6ec51b3628deafb Mon Sep 17 00:00:00 2001 From: Zubair Hassan Date: Sun, 16 Nov 2025 17:57:46 +0500 Subject: [PATCH 1/2] [Docs] Clarify behavior of View.http_method_not_allowed default implementation --- docs/ref/class-based-views/base.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/ref/class-based-views/base.txt b/docs/ref/class-based-views/base.txt index c1b302ea6a..edf2dab5fe 100644 --- a/docs/ref/class-based-views/base.txt +++ b/docs/ref/class-based-views/base.txt @@ -113,8 +113,14 @@ ancestor classes are documented under the section title of **Ancestors If the view was called with an HTTP method it doesn't support, this method is called instead. - The default implementation returns ``HttpResponseNotAllowed`` with a - list of allowed methods in plain text. + The default implementation returns ``HttpResponseNotAllowed`` with + status code ``405 Method Not Allowed``. + + .. note:: + + Django sets the list of allowed HTTP methods in the ``Allow`` + response header, and the response content is empty. + .. method:: options(request, *args, **kwargs) From 1ccad66d6397ad0f0373fb100e2b24e8b9334c4f Mon Sep 17 00:00:00 2001 From: Zubair Hassan Date: Sun, 16 Nov 2025 18:42:35 +0500 Subject: [PATCH 2/2] [Docs] RFC refrence added --- docs/ref/class-based-views/base.txt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/docs/ref/class-based-views/base.txt b/docs/ref/class-based-views/base.txt index edf2dab5fe..fbb2da9a6e 100644 --- a/docs/ref/class-based-views/base.txt +++ b/docs/ref/class-based-views/base.txt @@ -113,13 +113,9 @@ ancestor classes are documented under the section title of **Ancestors If the view was called with an HTTP method it doesn't support, this method is called instead. - The default implementation returns ``HttpResponseNotAllowed`` with - status code ``405 Method Not Allowed``. - - .. note:: - - Django sets the list of allowed HTTP methods in the ``Allow`` - response header, and the response content is empty. + The default implementation returns ``HttpResponseNotAllowed`` with the + list of allowed methods in the ``Allow`` header. The response body is + empty, as required by :rfc:`RFC 7231 <7231#section-6.5.5>`. .. method:: options(request, *args, **kwargs)