Opened 21 months ago

Closed 21 months ago

Last modified 20 months ago

#30825 closed Bug (worksforme)

Confusing message on the default Django home page mentioning the debug settings

Reported by: Therry van Neerven Owned by: KESHAV KUMAR
Component: Uncategorized Version: 2.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: yes

Description (last modified by Therry van Neerven)

When having no home page configured and when running the configuration with DEBUG=False the following message is shown:

You are seeing this page because DEBUG=True is in your settings file and you have not configured any URLs.

(Check the attachment for a screenshot)

This message is confusing as I'm running Django with DEBUG=False.
Also I have configured URLs, but they are not at the root of the project.

I believe that this message should be improved and stating that a the user should configure a route to replace the default page.

Update: I noticed that for this specific view the engine is forced to be in debug [source]
I still believe that the message should be changed in order to communicate correctly what's going on.

Attachments (1)

django-home-page-debug-message.png (41.8 KB) - added by Therry van Neerven 21 months ago.
default home page

Download all attachments as: .zip

Change History (8)

Changed 21 months ago by Therry van Neerven

default home page

comment:1 Changed 21 months ago by Therry van Neerven

Description: modified (diff)

comment:2 Changed 21 months ago by Therry van Neerven

Description: modified (diff)

comment:3 Changed 21 months ago by KESHAV KUMAR

Owner: changed from nobody to KESHAV KUMAR
Status: newassigned

comment:4 Changed 21 months ago by Carlton Gibson

Resolution: worksforme
Status: assignedclosed

The debug view is not shown when DEBUG=False. Instead a generic 404 is show.

Unless you can provide reproduce steps, this isn't something we need to fix.

  1. django-admin startproject ticket_30825
  2. cd ticket_30825/
  3. Edit settings.py with
    DEBUG = False
    ALLOWED_HOSTS = ['*']
  1. ./manage.py runserver
  2. curl -i http://127.0.0.1:8000
HTTP/1.1 404 Not Found
Date: Wed, 02 Oct 2019 14:59:27 GMT
Server: WSGIServer/0.2 CPython/3.7.3
Content-Type: text/html
X-Frame-Options: DENY
Content-Length: 179
X-Content-Type-Options: nosniff


<!doctype html>
<html lang="en">
<head>
  <title>Not Found</title>
</head>
<body>
  <h1>Not Found</h1><p>The requested resource was not found on this server.</p>
</body>
</html>

Last edited 21 months ago by Carlton Gibson (previous) (diff)

comment:5 in reply to:  4 Changed 21 months ago by Therry van Neerven

Replying to Carlton Gibson:

The debug view is not shown when DEBUG=False. Instead a generic 404 is show.

Unless you can provide reproduce steps, this isn't something we need to fix.

I've checked our project and I found out that the issue was caused by the configuration of the default_urlconf at the root url:

from django.contrib import admin
from django.urls import path
from django.views.debug import default_urlconf

urlpatterns = [
    path('', default_urlconf),
    path('admin/', admin.site.urls),
]

The problem is caused by the fact that the Template engine is different for this view:

# Minimal Django templates engine to render the error templates
# regardless of the project's TEMPLATES setting. Templates are
# read directly from the filesystem so that the error handler
# works even if the template loader is broken.
DEBUG_ENGINE = Engine(
    debug=True,
    libraries={'i18n': 'django.templatetags.i18n'},
)

I'm in favor of considering this a configuration error from the user's side. However if a better message can be provided that would be nice.

comment:6 Changed 21 months ago by Carlton Gibson

OK, so it's morning, and perhaps I need another coffee, but, I'm struggling to think of any reasonable circumstances in which this ends up in your urls.py:

from django.views.debug import default_urlconf

urlpatterns = [
    path('', default_urlconf),
    # ...
]

For me, this is so far out of expected practice that:

  • You'd need to be beyond beginner to even be able to end up here, and
  • So rare as to not merit additional code paths adding an better error message.

Nonetheless, do you have a particular patch in mind?

comment:7 in reply to:  6 Changed 20 months ago by Therry van Neerven

Replying to Carlton Gibson:

For me, this is so far out of expected practice that:

  • You'd need to be beyond beginner to even be able to end up here, and
  • So rare as to not merit additional code paths adding an better error message.

Nonetheless, do you have a particular patch in mind?

All the patches that I can think of introduce additional complexity.
Since this is an edge case I don't think it is is worthwhile to make changes to the current implementation.
For that reason I'm fine with leaving this bug closed unless more people are reporting that they end up in a similar situation.

Note: See TracTickets for help on using tickets.
Back to Top