Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Who generates the default page of django welcome page?

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.

like image 789
ShuSon Avatar asked Feb 19 '13 06:02

ShuSon


People also ask

How do I change the default page in Django?

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.

Which file has Django default configurations?

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.

What does the template represent in Django?

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.

What is Django bootstrap?

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.


2 Answers

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),
    …
]
like image 178
maciek Avatar answered Sep 21 '22 16:09

maciek


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

like image 32
Matt Deacalion Avatar answered Sep 23 '22 16:09

Matt Deacalion