[Django] #36734: Clarify documentation about default implementation of `http_method_not_allowed`

27 views
Skip to first unread message

Django

unread,
Nov 15, 2025, 9:53:58 AM11/15/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
-------------------------------------+-------------------------------------
Reporter: xingyu0618 | Type:
| Cleanup/optimization
Status: new | Component:
| Documentation
Version: 5.2 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
https://docs.djangoproject.com/en/5.2/ref/class-based-
views/base/#django.views.generic.base.View.http_method_not_allowed

The quoted description:

{{{
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 original description would make you assume that it returns
HttpResponseNotAllowed(http 405) **with content** containing a list of
allowed methods in plain text.

But in fact, the default implementation returns HttpResponseNotAllowed
**with headers[Allow]** containing a list of allowed methods in plain
text, not in the content.

{{{
class TestView(View):
def get(self):
return HttpResponse('ok')

class Test(TestCase):
def test(self):
resp = self.client.post('/test')

# The content is empty.
# Allowed methods are in headers['Allow'].
self.assertEqual(resp.content, b'')
self.assertEqual(resp.headers['Allow'], 'GET, HEAD, OPTIONS')
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36734>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 15, 2025, 10:33:54 AM11/15/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
-------------------------------------+-------------------------------------
Reporter: xingyu lin | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by xingyu lin:

Old description:

> https://docs.djangoproject.com/en/5.2/ref/class-based-
> views/base/#django.views.generic.base.View.http_method_not_allowed
>
> The quoted description:
>
> {{{
> 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 original description would make you assume that it returns
> HttpResponseNotAllowed(http 405) **with content** containing a list of
> allowed methods in plain text.
>
> But in fact, the default implementation returns HttpResponseNotAllowed
> **with headers[Allow]** containing a list of allowed methods in plain
> text, not in the content.
>
> {{{
> class TestView(View):
> def get(self):
> return HttpResponse('ok')
>
> class Test(TestCase):
> def test(self):
> resp = self.client.post('/test')
>
> # The content is empty.
> # Allowed methods are in headers['Allow'].
> self.assertEqual(resp.content, b'')
> self.assertEqual(resp.headers['Allow'], 'GET, HEAD, OPTIONS')
> }}}

New description:

https://docs.djangoproject.com/en/5.2/ref/class-based-
views/base/#django.views.generic.base.View.http_method_not_allowed

The quoted description:

{{{
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 original description would make you assume that it returns
HttpResponseNotAllowed(http 405) **with content** containing a list of
allowed methods in plain text.

But in fact, the default implementation returns HttpResponseNotAllowed
**with headers[Allow]** containing a list of allowed methods in plain
text, not in the content.

{{{
class TestView(View):
def get(self, req):
return HttpResponse('ok')

class Test(TestCase):
def test(self):
resp = self.client.post('/test')

# The content is empty.
# Allowed methods are in headers['Allow'].
self.assertEqual(resp.content, b'')
self.assertEqual(resp.headers['Allow'], 'GET, HEAD, OPTIONS')
}}}

--
--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:1>

Django

unread,
Nov 16, 2025, 7:10:25 AM11/16/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
-------------------------------------+-------------------------------------
Reporter: xingyu lin | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by zubair):

Please assign this ticket to me, i am working on this.
--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:2>

Django

unread,
Nov 16, 2025, 7:21:37 AM11/16/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
-------------------------------------+-------------------------------------
Reporter: xingyu lin | Owner: zubair
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by xingyu lin):

* owner: (none) => zubair
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:3>

Django

unread,
Nov 16, 2025, 8:09:11 AM11/16/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
-------------------------------------+-------------------------------------
Reporter: xingyu lin | Owner: zubair
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by zubair):

This is the pull request i have created for this ticket.

https://github.com/django/django/pull/20181
--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:4>

Django

unread,
Nov 16, 2025, 8:12:36 AM11/16/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
-------------------------------------+-------------------------------------
Reporter: xingyu lin | Owner: zubair
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by xingyu lin):

Got it, thanks for your work.
--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:5>

Django

unread,
Nov 16, 2025, 8:41:16 AM11/16/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
-------------------------------------+-------------------------------------
Reporter: xingyu lin | Owner: zubair
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Youngkwang Yang):

I think it would be good to add an RFC reference.

like:

{{{
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>`.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:6>

Django

unread,
Nov 16, 2025, 9:07:44 AM11/16/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
-------------------------------------+-------------------------------------
Reporter: xingyu lin | Owner: zubair
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by zubair):

RFC reference added.
--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:7>

Django

unread,
Nov 16, 2025, 9:10:36 AM11/16/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
-------------------------------------+-------------------------------------
Reporter: xingyu lin | Owner: zubair
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by zubair):

Replying to [comment:5 xingyu lin]:
> Got it, thanks for your work.

You are most welcome.
And thank you for your kind and quick response.
--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:8>

Django

unread,
Nov 17, 2025, 3:00:01 AM11/17/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
-------------------------------------+-------------------------------------
Reporter: xingyu lin | Owner: zubair
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Youngkwang Yang):

* cc: Youngkwang Yang (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:9>

Django

unread,
Nov 17, 2025, 6:14:34 AM11/17/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
-------------------------------------+-------------------------------------
Reporter: xingyu lin | Owner: zubair
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by zubair):

Please merge this PR.
--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:10>

Django

unread,
Nov 17, 2025, 7:42:27 AM11/17/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
-------------------------------------+-------------------------------------
Reporter: xingyu lin | Owner: zubair
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Youngkwang Yang):

Replying to [comment:10 zubair]:
> Please merge this PR.


Just a note: this ticket is still in "Unreviewed" stage. A Django core
developer
will need to triage and accept it before merging. Let's wait for their
review.

See the contribution process here:
https://docs.djangoproject.com/en/dev/internals/contributing/triaging-
tickets/#triage-stages
--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:11>

Django

unread,
Nov 19, 2025, 10:14:19 AM11/19/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
--------------------------------------+------------------------------------
Reporter: xingyu lin | Owner: zubair
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Jacob Walls):

* stage: Unreviewed => Accepted
* version: 5.2 => dev

--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:12>

Django

unread,
Nov 19, 2025, 10:14:49 AM11/19/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
--------------------------------------+------------------------------------
Reporter: xingyu lin | Owner: zubair
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Jacob Walls):

* has_patch: 0 => 1
* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:13>

Django

unread,
Nov 20, 2025, 3:51:39 PM11/20/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
-------------------------------------+-------------------------------------
Reporter: xingyu lin | Owner: zubair
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:14>

Django

unread,
Nov 20, 2025, 3:53:03 PM11/20/25
to django-...@googlegroups.com
#36734: Clarify documentation about default implementation of
`http_method_not_allowed`
-------------------------------------+-------------------------------------
Reporter: xingyu lin | Owner: zubair
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: dev
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"ff843bcbce1f7fc16fcc4d4810c221a2eb11c167" ff843bc]:
{{{#!CommitTicketReference repository=""
revision="ff843bcbce1f7fc16fcc4d4810c221a2eb11c167"
Fixed #36734 -- Clarified the behavior of View.http_method_not_allowed.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36734#comment:15>
Reply all
Reply to author
Forward
0 new messages