Code

Ticket #7269: debug.py.3.diff

File debug.py.3.diff, 2.0 KB (added by Carl Karsten <carl@…>, 6 years ago)

added "Note:...not always usable..."

Line 
1Index: views/debug.py
2===================================================================
3--- views/debug.py      (revision 7548)
4+++ views/debug.py      (working copy)
5@@ -178,12 +178,13 @@
6         if not tried:
7             # tried exists but is an empty list. The URLconf must've been empty.
8             return empty_urlconf(request)
9+    urlpatterns = [(t,t.strip('^$')) for t in tried]
10 
11     t = Template(TECHNICAL_404_TEMPLATE, name='Technical 404 template')
12     c = Context({
13         'root_urlconf': settings.ROOT_URLCONF,
14         'request_path': request.path[1:], # Trim leading slash
15-        'urlpatterns': tried,
16+        'urlpatterns': urlpatterns,
17         'reason': str(exception),
18         'request': request,
19         'request_protocol': request.is_secure() and "https" or "http",
20@@ -696,11 +697,11 @@
21       Django tried these URL patterns, in this order:
22       </p>
23       <ol>
24-        {% for pattern in urlpatterns %}
25-          <li>{{ pattern }}</li>
26+        {% for pattern,guess in urlpatterns %}
27+          <li><a href="{{ guess }}">{{ pattern }}</a</li>
28         {% endfor %}
29       </ol>
30-      <p>The current URL, <code>{{ request_path|escape }}</code>, didn't match any of these.</p>
31+      <p>The current URL, "<code>{{ request_path|escape }}</code>", didn't match any of these.</p>
32     {% else %}
33       <p>{{ reason }}</p>
34     {% endif %}
35@@ -710,8 +711,17 @@
36     <p>
37       You're seeing this error because you have <code>DEBUG = True</code> in
38       your Django settings file. Change that to <code>False</code>, and Django
39-      will display a standard 404 page.
40+      will display your custom 404 page.
41     </p>
42+    <br>
43+    <p>
44+      Note: The above links are formed using .strip('^$').replace(' ','')
45+      This does not always result in a usable link,
46+      but when it does, it is handy. 
47+      <!-- With enough work it might be posible to craft valid URLs.
48+      feel free to do the work and submit it. -->
49+    </p>
50+
51   </div>
52 </body>
53 </html>