! .
URL-, Django ( ). .
URL , django Not found: {url}
, runserver
. 404, .
debug
.
django/views/debug.py
:
def technical_404_response(request, exception):
if (not tried
or (request.path == '/'
and len(tried) == 1
and len(tried[0]) == 1
and getattr(tried[0][0], 'app_name', '') == getattr(tried[0][0], 'namespace', '') == 'admin')):
return default_urlconf(request)
Django , , URL- . , default_urlconf
.
:
- URL
- URL- '/', URL,
admin
app
, , URL , Django default_urlconf
. URL admin
, URL-. - :
Not Found: /random/url/
[11/Feb/2016 04:24:23] "GET /random/url/ HTTP/1.1" 200 1767
default_urlconf
:
def default_urlconf(request):
"Create an empty URLconf 404 error response."
t = DEBUG_ENGINE.from_string(DEFAULT_URLCONF_TEMPLATE)
c = Context({
"title": _("Welcome to Django"),
"heading": _("It worked!"),
"subheading": _("Congratulations on your first Django-powered page."),
"instructions": _("Of course, you haven't actually done any work yet. "
"Next, start your first app by running <code>python manage.py startapp [app_label]</code>."),
"explanation": _("You're seeing this message because you have <code>DEBUG = True</code> in your "
"Django settings file and you haven't configured any URLs. Get to work!"),
})
return HttpResponse(t.render(c), content_type='text/html')
( HTTP- HttpResponse
= > 200)