Who creates the default django welcome page?
I just installed django environment and as the tutorial said. I dialed python manager.py runserver
and he told me to open 127.0.0.1:8000
. When I open it, it worked with the correct welcome page.
But here's my question: who generates this default welcome page? Since no views.py
, and the page is urls.py
blank.
source to share
Take a look at django/core/handlers/base.py
and django/views/debug.py
. In a nutshell, if django gets 404, what if you don't have any routes then in base.py
if settings.DEBUG:
from django.views import debug
response = debug.technical_404_response(request, e)
And in debug.py look technical_404_response
andempty_urlconf
source to share
If your urls.py is empty (nor does it contain templates to match urls) and Django is in debug mode (DEBUG = True in settings.py), then Django returns that page you see.
You can see it in the code here: https://github.com/django/django/blob/master/django/views/debug.py#L1062-L1110
source to share