#36332: Usage notes and examples for HttpRequest.path_info and
HttpRequest.get_full_path_info() in docs are mixed up
-------------------------------------+-------------------------------------
Reporter: Kashemir001 | Type:
| Cleanup/optimization
Status: new | Component:
| Documentation
Version: 5.2 | Severity: Normal
Keywords: wsgi httprequest | Triage Stage:
path_info | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Documentation for [https://docs.djangoproject.com/en/5.2/ref/request-
response/#django.http.HttpRequest.get_full_path_info
HttpRequest.get_full_path_info()] gives the returning value example:
{{{
Example: "/minfo/music/bands/the_beatles/?print=true"
}}}
which implies that the script prefix part, here {{{/minfo}}}, is contained
in the returning value of {{{HttpRequest.path_info}}}.
Now, docs for [https://docs.djangoproject.com/en/5.2/ref/request-
response/#django.http.HttpRequest.path_info path_info itself] say:
{{{
For example, if the WSGIScriptAlias for your application is set to
"/minfo", then ``path`` might be "/minfo/music/bands/the_beatles/" and
``path_info`` would be "/music/bands/the_beatles/".
}}}
which implies that prefix part is not contained in
{{{HttpRequest.path_info}}}, but in {{{HttpRequest.path}}}. This
contradicts previous example.
Looking at the
[https://github.com/django/django/blob/main/tests/requests_tests/tests.py#L54
unit test] for the subject, prefix is actually expected to be included in
{{{path_info}}}. Therefore, the correct example for
[https://docs.djangoproject.com/en/5.2/ref/request-
response/#django.http.HttpRequest.path_info path_info] should say:
{{{
For example, if the WSGIScriptAlias for your application is set to
"/minfo", then ``path`` might be "/music/bands/the_beatles/" and
``path_info`` would be "/minfo/music/bands/the_beatles/".
}}}
The usage notes for both attributes should be updated as well, so both
sections updated might look like:
{{{
``HttpRequest.path``
A string representing the path to the requested page, not including the
scheme, domain, script prefix, or query string.
Example: "/music/bands/the_beatles/"
Under some web server configurations, the portion of the URL after the
host name is split up into a script prefix portion and a path info
portion. The ``path`` attribute always contains the path info portion of
the path, no matter what web server is being used. Using this instead of
``path_info`` can make your code easier to move between test and
deployment servers.
For example, If the WSGIScriptAlias for your application is set to
"/minfo", then ``path`` might be "/music/bands/the_beatles/" and
``path_info`` would be "/minfo/music/bands/the_beatles/".
``HttpRequest.path_info``
The ``path_info`` attribute contains the full path, including both the
script prefix portion and the path info portion of the path, unlike the
``path`` attribute.
Example: "/minfo/music/bands/the_beatles/"
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36332>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019643d78057-4e3b28ab-59c7-4f84-ba88-afb4859ee23e-000000%40eu-central-1.amazonses.com.