Opened 9 years ago

Closed 9 years ago

#10787 closed (duplicate) Templates: Request URLs Should Include django.root

Reported by: Rick Wagner Owned by: nobody
Component: Generic views Version: master
Severity: Keywords: debug
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no



In a few place in [browser:django/trunk/django/views/] a string is built to show the request, like so:

      <th>Request URL:</th>
      <td>{{ request_protocol }}://{{ request.META.HTTP_HOST }}{{ request.path_info|escape }}</td>

However, request.path_info is only relative to root URL of which ever settings module is being used. To correct this, the script name (e.g., django.root for Apache and mod_python), should be added.

      <th>Request URL:</th>
      <td>{{ request_protocol }}://{{ request.META.HTTP_HOST }}{{ request.META.SCRIPT_NAME }}{{ request.path_info|escape }}</td>

One way to do this would be to modify request.path_info, but I don't think that would be correct. In particular, when listing a 404, the URLs shown should probably only be those be checked for matches, which are "below" the root URL. But, anywhere that lists the protocol, host, and path, should be corrected to match what's in the browser (or queried by a script, etc.).

From what I can see, the following lines should be updated:

  • [browser:django/trunk/django/views/ 402]
  • [browser:django/trunk/django/views/ 532]
  • [browser:django/trunk/django/views/ 744]

I'm hesitating on provding a patch, since I'm not sure if request.META['SCRIPT_NAME'] is always set, and where the trailing slashes are.


Change History (3)

comment:1 Changed 9 years ago by Rick Wagner

Correction to my bad use of Trac linking. Here are the line numbers, with working links to the revision I was looking at:

  • [source:/django/trunk/django/views/ 402]
  • [source:/django/trunk/django/views/ 532]
  • [source:/django/trunk/django/views/ 744]


comment:2 Changed 9 years ago by Alex Gaynor

Triage Stage: UnreviewedAccepted

comment:3 Changed 9 years ago by Sean Brant

Resolution: duplicate
Status: newclosed

This was a dupe of #9577 and fixed by r10535.

Note: See TracTickets for help on using tickets.
Back to Top