Skip to content

Instantly share code, notes, and snippets.

@lcd1232
Created October 16, 2020 19:02
Show Gist options
  • Save lcd1232/f242d88b1eaeaccbb6ba2e81e68644cd to your computer and use it in GitHub Desktop.
Save lcd1232/f242d88b1eaeaccbb6ba2e81e68644cd to your computer and use it in GitHub Desktop.
Minimal django app for bug
<html></html>

How to reproduce: $ django-admin runserver --pythonpath=. --settings=tinyapp Then open in browser URL http://127.0.0.1:8000/123 and see "Server Error (500)". Look at the console and see there is no stack trace

import os
from django.conf.urls import url
from django.http import HttpResponse
DEBUG = False
ALLOWED_HOSTS = ["*"]
SECRET_KEY = '4l0ngs3cr3tstr1ngw3lln0ts0l0ngw41tn0w1tsl0ng3n0ugh'
ROOT_URLCONF = __name__
def home(request):
return HttpResponse('Hello world')
urlpatterns = [
url(r'^$', home),
]
TEMPLATES = [{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.dirname(os.path.realpath(__file__))],
"OPTIONS": {
"context_processors": ["tinyapp.context_proc"],
},
}
]
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"filters": {"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"}},
"formatters": {
"verbose": {
"format": "%(levelname)s %(asctime)s %(module)s "
"%(process)d %(thread)d %(message)s"
}
},
"handlers": {
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "verbose",
},
},
"root": {"level": "INFO", "handlers": ["console"]},
"loggers": {
"django.request": {
"handlers": ["console"],
"level": "ERROR",
"propagate": True,
},
"django.security.DisallowedHost": {
"level": "ERROR",
"handlers": ["console"],
"propagate": True,
},
},
}
def context_proc(request):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment