I just set up the django environment and as the tutorial said. I typed python manager.py runserver
and it told me to open 127.0.0.1:8000
. When I open it, it worked with the correct welcome page.
But here is my question: who generates this default welcome page? Since there is no views.py
and the urls.py
page is empty.
Yes it's possible. I added a new dir in main project, and inside it __init__.py and views.py , and in the main urls.py add from new_dir import views , and add to urlpatterns : path('', views. home_view, name='home' ). And reload the server.
These defaults live in the module django/conf/global_settings.py . Here's the algorithm Django uses in compiling settings: Load settings from global_settings.py . Load settings from the specified settings file, overriding the global settings as necessary.
A Django template is a text document or a Python string marked-up using the Django template language. Some constructs are recognized and interpreted by the template engine. The main ones are variables and tags. A template is rendered with a context.
Django with Bootstrap. Bootstrap is a framework which is used to create user interface in web applications. It provides css, js and other tools that help to create required interface. In Django, we can use bootstrap to create more user friendly applications.
If anyone would like to have it back (or reuse it), you just need to add debug.default_urlconf
view to your urls
:
…
from django.views import debug
…
urlpatterns = [
…
path('', debug.default_urlconf),
…
]
If your urls.py
is empty (as in contains no patterns to match urls) and Django is in debug mode (DEBUG = True
in your settings) then Django fires back the page you're seeing.
The Django view:
https://github.com/django/django/blob/main/django/views/debug.py#L575-L583
The HTML template:
https://github.com/django/django/blob/ca9872905559026af82000e46cde6f7dedc897b6/django/views/templates/default_urlconf.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With