Django

Code

Changeset 1552

Show
Ignore:
Timestamp:
12/05/05 23:04:56 (3 years ago)
Author:
adrian
Message:

Debug 400 page now displays special error message if your URLconf is empty.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/views/debug.py

    r1407 r1552  
    129129    exception. 
    130130    """ 
     131    urlconf_is_empty = False 
    131132    try: 
    132133        tried = exception.args[0]['tried'] 
    133134    except (IndexError, TypeError): 
    134135        tried = [] 
     136    else: 
     137        if not tried: 
     138            # tried exists but is an empty list. The URLconf must've been empty. 
     139            urlconf_is_empty = True 
    135140 
    136141    t = Template(TECHNICAL_404_TEMPLATE) 
     
    138143        'root_urlconf': settings.ROOT_URLCONF, 
    139144        'urlpatterns': tried, 
     145        'urlconf_is_empty': urlconf_is_empty, 
    140146        'reason': str(exception), 
    141147        'request': request, 
     
    534540  </div> 
    535541  <div id="info"> 
    536     {% if urlpatterns %} 
    537       <p> 
     542    {% if urlconf_is_empty %} 
     543      <p>Your URLconf, <code>{{ settings.ROOT_URLCONF }}</code>, was empty.</p> 
     544    {% else %} 
     545      {% if urlpatterns %} 
     546        <p> 
    538547        Using the URLconf defined in <code>{{ settings.ROOT_URLCONF }}</code>, 
    539548        Django tried these URL patterns, in this order: 
    540       </p> 
    541       <ol> 
    542         {% for pattern in urlpatterns %} 
    543           <li>{{ pattern|escape }}</li> 
    544         {% endfor %} 
    545       </ol> 
    546       <p>The current URL, <code>{{ request.path }}</code>, didn't match any of these.</p> 
    547     {% else %} 
    548       <p>{{ reason|escape }}</p> 
     549        </p> 
     550        <ol> 
     551          {% for pattern in urlpatterns %} 
     552            <li>{{ pattern|escape }}</li> 
     553          {% endfor %} 
     554        </ol> 
     555        <p>The current URL, <code>{{ request.path }}</code>, didn't match any of these.</p> 
     556      {% else %} 
     557        <p>{{ reason|escape }}</p> 
     558      {% endif %} 
    549559    {% endif %} 
    550560  </div>