Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Re: [Django] #36332: Usage notes and examples for HttpRequest.path and HttpRequest.path_info in docs are mixed up

13 views
Skip to first unread message

Django

unread,
Apr 17, 2025, 11:20:07 AMApr 17
to django-...@googlegroups.com
#36332: Usage notes and examples for HttpRequest.path and HttpRequest.path_info in
docs are mixed up
-------------------------------------+-------------------------------------
Reporter: Kashemir001 | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: wsgi httprequest | Triage Stage: Accepted
path_info |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Unreviewed => Accepted

Comment:

I agree that the examples are mixed up and we should have the following:
{{{#!diff
--- a/docs/ref/request-response.txt
+++ b/docs/ref/request-response.txt
@@ -351,14 +351,14 @@ Methods

Returns the ``path``, plus an appended query string, if applicable.

- Example: ``"/music/bands/the_beatles/?print=true"``
+ Example: ``"/minfo/music/bands/the_beatles/?print=true"``

.. method:: HttpRequest.get_full_path_info()

Like :meth:`get_full_path`, but uses :attr:`path_info` instead of
:attr:`path`.

- Example: ``"/minfo/music/bands/the_beatles/?print=true"``
+ Example: ``"/music/bands/the_beatles/?print=true"``
}}}

The test you have linked seems to be a misleading test, the prefix is in
path rather than path info see:
-
https://github.com/django/django/blob/d755a98b8438c10f3cff61303ceb1fe16d414e9b/django/core/handlers/wsgi.py#L67
-
https://github.com/django/django/blob/d755a98b8438c10f3cff61303ceb1fe16d414e9b/django/core/handlers/asgi.py#L57
-
https://github.com/django/django/blob/d755a98b8438c10f3cff61303ceb1fe16d414e9b/tests/handlers/tests.py#L345

Would you like to create a PR?
--
Ticket URL: <https://code.djangoproject.com/ticket/36332#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 17, 2025, 3:03:13 PMApr 17
to django-...@googlegroups.com
#36332: Usage notes and examples for HttpRequest.path and HttpRequest.path_info in
docs are mixed up
-------------------------------------+-------------------------------------
Reporter: Kashemir001 | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: wsgi httprequest | Triage Stage: Accepted
path_info |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Kashemir001):

Replying to [comment:2 Sarah Boyce]:
> Would you like to create a PR?
> It might make sense to also update the linked test to be less misleading

Alright, I'll give it a go. Will switching attribute values and
corresponding asserts be enough for the tests? Something about:

{{{#!diff
--- a/tests/requests_tests/tests.py
+++ b/tests/requests_tests/tests.py
@@ -54,17 +54,17 @@
def test_httprequest_full_path(self):
request = HttpRequest()
- request.path = "/;some/?awful/=path/foo:bar/"
- request.path_info = "/prefix" + request.path
+ request.path_info = "/;some/?awful/=path/foo:bar/"
+ request.path = "/prefix" + request.path_info
request.META["QUERY_STRING"] = ";some=query&+query=string"
expected =
"/%3Bsome/%3Fawful/%3Dpath/foo:bar/?;some=query&+query=string"
- self.assertEqual(request.get_full_path(), expected)
- self.assertEqual(request.get_full_path_info(), "/prefix" +
expected)
+ self.assertEqual(request.get_full_path_info(), expected)
+ self.assertEqual(request.get_full_path(), "/prefix" + expected)

def test_httprequest_full_path_with_query_string_and_fragment(self):
request = HttpRequest()
- request.path = "/foo#bar"
- request.path_info = "/prefix" + request.path
+ request.path_info = "/foo#bar"
+ request.path = "/prefix" + request.path_info
request.META["QUERY_STRING"] = "baz#quux"
- self.assertEqual(request.get_full_path(), "/foo%23bar?baz#quux")
- self.assertEqual(request.get_full_path_info(),
"/prefix/foo%23bar?baz#quux")
+ self.assertEqual(request.get_full_path_info(),
"/foo%23bar?baz#quux")
+ self.assertEqual(request.get_full_path(),
"/prefix/foo%23bar?baz#quux")

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

Django

unread,
Apr 18, 2025, 9:52:46 AMApr 18
to django-...@googlegroups.com
#36332: Usage notes and examples for HttpRequest.path and HttpRequest.path_info in
docs are mixed up
-------------------------------------+-------------------------------------
Reporter: Kashemir001 | Owner:
Type: | Kashemir001
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: wsgi httprequest | Triage Stage: Accepted
path_info |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Kashemir001):

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

--
Ticket URL: <https://code.djangoproject.com/ticket/36332#comment:4>

Django

unread,
Apr 18, 2025, 10:17:04 AMApr 18
to django-...@googlegroups.com
#36332: Usage notes and examples for HttpRequest.path and HttpRequest.path_info in
docs are mixed up
-------------------------------------+-------------------------------------
Reporter: Kashemir001 | Owner:
Type: | Kashemir001
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: wsgi httprequest | Triage Stage: Accepted
path_info |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Kashemir001):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36332#comment:5>

Django

unread,
Apr 18, 2025, 10:17:35 AMApr 18
to django-...@googlegroups.com
#36332: Usage notes and examples for HttpRequest.path and HttpRequest.path_info in
docs are mixed up
-------------------------------------+-------------------------------------
Reporter: Kashemir001 | Owner:
Type: | Kashemir001
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: wsgi httprequest | Triage Stage: Accepted
path_info |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Kashemir001):

[https://github.com/django/django/pull/19392 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/36332#comment:6>

Django

unread,
May 13, 2025, 10:44:15 AMMay 13
to django-...@googlegroups.com
#36332: Usage notes and examples for HttpRequest.path and HttpRequest.path_info in
docs are mixed up
-------------------------------------+-------------------------------------
Reporter: Kashemir001 | Owner:
Type: | Kashemir001
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: wsgi httprequest | Triage Stage: Ready for
path_info | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36332#comment:7>

Django

unread,
May 13, 2025, 11:41:28 AMMay 13
to django-...@googlegroups.com
#36332: Usage notes and examples for HttpRequest.path and HttpRequest.path_info in
docs are mixed up
-------------------------------------+-------------------------------------
Reporter: Kashemir001 | Owner:
Type: | Kashemir001
Cleanup/optimization | Status: closed
Component: Documentation | Version: 5.2
Severity: Normal | Resolution: fixed
Keywords: wsgi httprequest | Triage Stage: Ready for
path_info | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

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

Comment:

In [changeset:"96c79be4e436f0b3045421556a2253cbff4533dc" 96c79be4]:
{{{#!CommitTicketReference repository=""
revision="96c79be4e436f0b3045421556a2253cbff4533dc"
Fixed #36332 -- Corrected HttpRequest.get_full_path() and
HttpRequest.get_full_path_info() examples.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36332#comment:8>
Reply all
Reply to author
Forward
0 new messages