Ticket #13542: debug_404_links.diff

File debug_404_links.diff, 1.2 KB (added by Erik Wognsen, 15 years ago)
  • django/views/debug.py

     
    275275            # tried exists but is an empty list. The URLconf must've been empty.
    276276            return empty_urlconf(request)
    277277
     278    # Make the debug 404 list URL patterns as links where applicable:
     279
     280    # The patterns need to be output as safe to render the links, so escape
     281    # them now before the the links are added
     282    tried = map(escape, tried)
     283
     284    for pattern in tried:
     285        match = re.match('\^([/\w]*)\$?$', pattern)
     286        if match:
     287            tried[tried.index(pattern)] = (
     288                    u'<a href="/{0}">{1}</a>'.format(match.group(1), pattern))
     289
    278290    t = Template(TECHNICAL_404_TEMPLATE, name='Technical 404 template')
    279291    c = Context({
    280292        'root_urlconf': settings.ROOT_URLCONF,
     
    778790      </p>
    779791      <ol>
    780792        {% for pattern in urlpatterns %}
    781           <li>{{ pattern }}</li>
     793          <li>{{ pattern|safe }}</li>
    782794        {% endfor %}
    783795      </ol>
    784796      <p>The current URL, <code>{{ request_path|escape }}</code>, didn't match any of these.</p>
Back to Top