Ticket #7269: debug.py.4.diff

File debug.py.4.diff, 1.9 KB (added by CarlFK, 16 years ago)

applies cleanly to svnversion 9035M

  • django/views/debug.py

     
    251251            # tried exists but is an empty list. The URLconf must've been empty.
    252252            return empty_urlconf(request)
    253253
     254    # make a URL that might be useful to the developer
     255    # remove whitespace and typical regex
     256    urlpatterns = [(t,t.strip('^$').replace(' ','')) for t in tried]
     257
    254258    t = Template(TECHNICAL_404_TEMPLATE, name='Technical 404 template')
    255259    c = Context({
    256260        'root_urlconf': settings.ROOT_URLCONF,
    257261        'request_path': request.path_info[1:], # Trim leading slash
    258         'urlpatterns': tried,
     262        'urlpatterns': urlpatterns,
    259263        'reason': smart_str(exception, errors='replace'),
    260264        'request': request,
    261265        'request_protocol': request.is_secure() and "https" or "http",
     
    728732      Django tried these URL patterns, in this order:
    729733      </p>
    730734      <ol>
    731         {% for pattern in urlpatterns %}
    732           <li>{{ pattern }}</li>
     735        {% for pattern,guess in urlpatterns %}
     736            <li><a href="/{{ guess }}">{{ pattern }}</a</li>
    733737        {% endfor %}
    734738      </ol>
    735739      <p>The current URL, <code>{{ request_path|escape }}</code>, didn't match any of these.</p>
     
    742746    <p>
    743747      You're seeing this error because you have <code>DEBUG = True</code> in
    744748      your Django settings file. Change that to <code>False</code>, and Django
    745       will display a standard 404 page.
     749      will display your custom 404 page.
    746750    </p>
     751    <br>
     752    <p>
     753      Note: The above links are formed using .strip('^$').replace(' ','')
     754      which does not always result in a usable link.
     755      When it does, it is handy. 
     756      <!-- With enough work it might be posible to craft valid URLs.
     757      feel free to do the work and submit it. -->
     758    </p>
     759
    747760  </div>
    748761</body>
    749762</html>
Back to Top