2010-02-25 05:58:01 +08:00
|
|
|
import datetime
|
2007-12-11 13:38:34 +08:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
2005-11-15 01:44:50 +08:00
|
|
|
from django.conf import settings
|
2010-02-25 05:58:01 +08:00
|
|
|
from django.http import HttpResponse, HttpResponseServerError, HttpResponseNotFound
|
|
|
|
from django.template import (Template, Context, TemplateDoesNotExist,
|
|
|
|
TemplateSyntaxError)
|
2005-11-24 07:10:17 +08:00
|
|
|
from django.utils.html import escape
|
2009-03-19 00:55:59 +08:00
|
|
|
from django.utils.importlib import import_module
|
2008-08-26 06:47:07 +08:00
|
|
|
from django.utils.encoding import smart_unicode, smart_str
|
2005-11-15 01:44:50 +08:00
|
|
|
|
2010-02-25 05:58:01 +08:00
|
|
|
|
2010-05-29 01:25:43 +08:00
|
|
|
HIDDEN_SETTINGS = re.compile('SECRET|PASSWORD|PROFANITIES_LIST|SIGNATURE')
|
2005-11-15 22:35:24 +08:00
|
|
|
|
2005-11-24 07:10:17 +08:00
|
|
|
def linebreak_iter(template_source):
|
2005-11-25 07:31:33 +08:00
|
|
|
yield 0
|
2005-11-24 08:06:36 +08:00
|
|
|
p = template_source.find('\n')
|
|
|
|
while p >= 0:
|
2005-11-25 08:04:06 +08:00
|
|
|
yield p+1
|
2005-11-24 08:06:36 +08:00
|
|
|
p = template_source.find('\n', p+1)
|
2005-11-24 07:10:17 +08:00
|
|
|
yield len(template_source) + 1
|
|
|
|
|
2010-01-31 10:30:02 +08:00
|
|
|
def cleanse_setting(key, value):
|
|
|
|
"""Cleanse an individual setting key/value of sensitive content.
|
|
|
|
|
|
|
|
If the value is a dictionary, recursively cleanse the keys in
|
|
|
|
that dictionary.
|
|
|
|
"""
|
2010-02-01 07:38:17 +08:00
|
|
|
try:
|
|
|
|
if HIDDEN_SETTINGS.search(key):
|
|
|
|
cleansed = '********************'
|
2010-01-31 10:30:02 +08:00
|
|
|
else:
|
2010-02-01 07:38:17 +08:00
|
|
|
if isinstance(value, dict):
|
|
|
|
cleansed = dict((k, cleanse_setting(k, v)) for k,v in value.items())
|
|
|
|
else:
|
|
|
|
cleansed = value
|
|
|
|
except TypeError:
|
|
|
|
# If the key isn't regex-able, just return as-is.
|
|
|
|
cleansed = value
|
2010-01-31 10:30:02 +08:00
|
|
|
return cleansed
|
|
|
|
|
2005-12-07 14:02:09 +08:00
|
|
|
def get_safe_settings():
|
|
|
|
"Returns a dictionary of the settings module, with sensitive settings blurred out."
|
|
|
|
settings_dict = {}
|
|
|
|
for k in dir(settings):
|
|
|
|
if k.isupper():
|
2010-01-31 10:30:02 +08:00
|
|
|
settings_dict[k] = cleanse_setting(k, getattr(settings, k))
|
2005-12-07 14:02:09 +08:00
|
|
|
return settings_dict
|
|
|
|
|
2005-11-15 01:44:50 +08:00
|
|
|
def technical_500_response(request, exc_type, exc_value, tb):
|
|
|
|
"""
|
2005-12-07 14:02:09 +08:00
|
|
|
Create a technical server error response. The last three arguments are
|
2005-11-15 01:44:50 +08:00
|
|
|
the values returned from sys.exc_info() and friends.
|
|
|
|
"""
|
2008-07-16 02:47:49 +08:00
|
|
|
reporter = ExceptionReporter(request, exc_type, exc_value, tb)
|
|
|
|
html = reporter.get_traceback_html()
|
2008-03-18 22:34:48 +08:00
|
|
|
return HttpResponseServerError(html, mimetype='text/html')
|
|
|
|
|
2008-07-16 02:47:49 +08:00
|
|
|
class ExceptionReporter:
|
|
|
|
"""
|
|
|
|
A class to organize and coordinate reporting on exceptions.
|
|
|
|
"""
|
|
|
|
def __init__(self, request, exc_type, exc_value, tb):
|
|
|
|
self.request = request
|
|
|
|
self.exc_type = exc_type
|
|
|
|
self.exc_value = exc_value
|
|
|
|
self.tb = tb
|
|
|
|
|
|
|
|
self.template_info = None
|
|
|
|
self.template_does_not_exist = False
|
|
|
|
self.loader_debug_info = None
|
|
|
|
|
|
|
|
# Handle deprecated string exceptions
|
|
|
|
if isinstance(self.exc_type, basestring):
|
|
|
|
self.exc_value = Exception('Deprecated String Exception: %r' % self.exc_type)
|
|
|
|
self.exc_type = type(self.exc_value)
|
|
|
|
|
|
|
|
def get_traceback_html(self):
|
|
|
|
"Return HTML code for traceback."
|
|
|
|
|
|
|
|
if issubclass(self.exc_type, TemplateDoesNotExist):
|
|
|
|
from django.template.loader import template_source_loaders
|
|
|
|
self.template_does_not_exist = True
|
|
|
|
self.loader_debug_info = []
|
|
|
|
for loader in template_source_loaders:
|
|
|
|
try:
|
2009-03-19 00:55:59 +08:00
|
|
|
module = import_module(loader.__module__)
|
|
|
|
source_list_func = module.get_template_sources
|
2008-07-16 02:47:49 +08:00
|
|
|
# NOTE: This assumes exc_value is the name of the template that
|
|
|
|
# the loader attempted to load.
|
|
|
|
template_list = [{'name': t, 'exists': os.path.exists(t)} \
|
|
|
|
for t in source_list_func(str(self.exc_value))]
|
|
|
|
except (ImportError, AttributeError):
|
|
|
|
template_list = []
|
2009-12-14 20:08:23 +08:00
|
|
|
if hasattr(loader, '__class__'):
|
|
|
|
loader_name = loader.__module__ + '.' + loader.__class__.__name__
|
|
|
|
else:
|
|
|
|
loader_name = loader.__module__ + '.' + loader.__name__
|
2008-07-16 02:47:49 +08:00
|
|
|
self.loader_debug_info.append({
|
2009-12-14 20:08:23 +08:00
|
|
|
'loader': loader_name,
|
2008-07-16 02:47:49 +08:00
|
|
|
'templates': template_list,
|
|
|
|
})
|
2010-02-25 05:58:01 +08:00
|
|
|
if (settings.TEMPLATE_DEBUG and hasattr(self.exc_value, 'source') and
|
|
|
|
isinstance(self.exc_value, TemplateSyntaxError)):
|
2008-07-16 02:47:49 +08:00
|
|
|
self.get_template_exception_info()
|
2008-02-03 10:24:56 +08:00
|
|
|
|
2008-07-16 02:47:49 +08:00
|
|
|
frames = self.get_traceback_frames()
|
2008-02-03 10:24:56 +08:00
|
|
|
|
2008-07-16 02:47:49 +08:00
|
|
|
unicode_hint = ''
|
|
|
|
if issubclass(self.exc_type, UnicodeError):
|
|
|
|
start = getattr(self.exc_value, 'start', None)
|
|
|
|
end = getattr(self.exc_value, 'end', None)
|
|
|
|
if start is not None and end is not None:
|
|
|
|
unicode_str = self.exc_value.args[1]
|
|
|
|
unicode_hint = smart_unicode(unicode_str[max(start-5, 0):min(end+5, len(unicode_str))], 'ascii', errors='replace')
|
|
|
|
from django import get_version
|
|
|
|
t = Template(TECHNICAL_500_TEMPLATE, name='Technical 500 template')
|
|
|
|
c = Context({
|
|
|
|
'exception_type': self.exc_type.__name__,
|
|
|
|
'exception_value': smart_unicode(self.exc_value, errors='replace'),
|
|
|
|
'unicode_hint': unicode_hint,
|
|
|
|
'frames': frames,
|
|
|
|
'lastframe': frames[-1],
|
|
|
|
'request': self.request,
|
|
|
|
'settings': get_safe_settings(),
|
|
|
|
'sys_executable': sys.executable,
|
|
|
|
'sys_version_info': '%d.%d.%d' % sys.version_info[0:3],
|
|
|
|
'server_time': datetime.datetime.now(),
|
|
|
|
'django_version_info': get_version(),
|
|
|
|
'sys_path' : sys.path,
|
|
|
|
'template_info': self.template_info,
|
|
|
|
'template_does_not_exist': self.template_does_not_exist,
|
|
|
|
'loader_debug_info': self.loader_debug_info,
|
|
|
|
})
|
|
|
|
return t.render(c)
|
|
|
|
|
|
|
|
def get_template_exception_info(self):
|
|
|
|
origin, (start, end) = self.exc_value.source
|
|
|
|
template_source = origin.reload()
|
|
|
|
context_lines = 10
|
|
|
|
line = 0
|
|
|
|
upto = 0
|
|
|
|
source_lines = []
|
|
|
|
before = during = after = ""
|
|
|
|
for num, next in enumerate(linebreak_iter(template_source)):
|
|
|
|
if start >= upto and end <= next:
|
|
|
|
line = num
|
|
|
|
before = escape(template_source[upto:start])
|
|
|
|
during = escape(template_source[start:end])
|
|
|
|
after = escape(template_source[end:next])
|
|
|
|
source_lines.append( (num, escape(template_source[upto:next])) )
|
|
|
|
upto = next
|
|
|
|
total = len(source_lines)
|
|
|
|
|
|
|
|
top = max(1, line - context_lines)
|
|
|
|
bottom = min(total, line + 1 + context_lines)
|
|
|
|
|
|
|
|
self.template_info = {
|
|
|
|
'message': self.exc_value.args[0],
|
|
|
|
'source_lines': source_lines[top:bottom],
|
|
|
|
'before': before,
|
|
|
|
'during': during,
|
|
|
|
'after': after,
|
|
|
|
'top': top,
|
|
|
|
'bottom': bottom,
|
|
|
|
'total': total,
|
|
|
|
'line': line,
|
|
|
|
'name': origin.name,
|
|
|
|
}
|
|
|
|
|
|
|
|
def _get_lines_from_file(self, filename, lineno, context_lines, loader=None, module_name=None):
|
|
|
|
"""
|
|
|
|
Returns context_lines before and after lineno from file.
|
|
|
|
Returns (pre_context_lineno, pre_context, context_line, post_context).
|
|
|
|
"""
|
|
|
|
source = None
|
|
|
|
if loader is not None and hasattr(loader, "get_source"):
|
|
|
|
source = loader.get_source(module_name)
|
|
|
|
if source is not None:
|
|
|
|
source = source.splitlines()
|
|
|
|
if source is None:
|
2005-11-25 05:15:51 +08:00
|
|
|
try:
|
2008-07-16 02:47:49 +08:00
|
|
|
f = open(filename)
|
|
|
|
try:
|
|
|
|
source = f.readlines()
|
|
|
|
finally:
|
|
|
|
f.close()
|
|
|
|
except (OSError, IOError):
|
|
|
|
pass
|
|
|
|
if source is None:
|
|
|
|
return None, [], None, []
|
|
|
|
|
|
|
|
encoding = 'ascii'
|
|
|
|
for line in source[:2]:
|
|
|
|
# File coding may be specified. Match pattern from PEP-263
|
|
|
|
# (http://www.python.org/dev/peps/pep-0263/)
|
|
|
|
match = re.search(r'coding[:=]\s*([-\w.]+)', line)
|
|
|
|
if match:
|
|
|
|
encoding = match.group(1)
|
|
|
|
break
|
|
|
|
source = [unicode(sline, encoding, 'replace') for sline in source]
|
|
|
|
|
|
|
|
lower_bound = max(0, lineno - context_lines)
|
|
|
|
upper_bound = lineno + context_lines
|
|
|
|
|
|
|
|
pre_context = [line.strip('\n') for line in source[lower_bound:lineno]]
|
|
|
|
context_line = source[lineno].strip('\n')
|
|
|
|
post_context = [line.strip('\n') for line in source[lineno+1:upper_bound]]
|
|
|
|
|
|
|
|
return lower_bound, pre_context, context_line, post_context
|
|
|
|
|
|
|
|
def get_traceback_frames(self):
|
|
|
|
frames = []
|
|
|
|
tb = self.tb
|
|
|
|
while tb is not None:
|
|
|
|
# support for __traceback_hide__ which is used by a few libraries
|
|
|
|
# to hide internal frames.
|
|
|
|
if tb.tb_frame.f_locals.get('__traceback_hide__'):
|
|
|
|
tb = tb.tb_next
|
|
|
|
continue
|
|
|
|
filename = tb.tb_frame.f_code.co_filename
|
|
|
|
function = tb.tb_frame.f_code.co_name
|
|
|
|
lineno = tb.tb_lineno - 1
|
|
|
|
loader = tb.tb_frame.f_globals.get('__loader__')
|
|
|
|
module_name = tb.tb_frame.f_globals.get('__name__')
|
|
|
|
pre_context_lineno, pre_context, context_line, post_context = self._get_lines_from_file(filename, lineno, 7, loader, module_name)
|
|
|
|
if pre_context_lineno is not None:
|
|
|
|
frames.append({
|
|
|
|
'tb': tb,
|
|
|
|
'filename': filename,
|
|
|
|
'function': function,
|
|
|
|
'lineno': lineno + 1,
|
|
|
|
'vars': tb.tb_frame.f_locals.items(),
|
|
|
|
'id': id(tb),
|
|
|
|
'pre_context': pre_context,
|
|
|
|
'context_line': context_line,
|
|
|
|
'post_context': post_context,
|
|
|
|
'pre_context_lineno': pre_context_lineno + 1,
|
|
|
|
})
|
2007-04-21 12:37:31 +08:00
|
|
|
tb = tb.tb_next
|
2005-11-17 11:10:03 +08:00
|
|
|
|
2008-07-16 02:47:49 +08:00
|
|
|
if not frames:
|
|
|
|
frames = [{
|
|
|
|
'filename': '<unknown>',
|
|
|
|
'function': '?',
|
|
|
|
'lineno': '?',
|
|
|
|
'context_line': '???',
|
|
|
|
}]
|
|
|
|
|
|
|
|
return frames
|
|
|
|
|
|
|
|
def format_exception(self):
|
|
|
|
"""
|
|
|
|
Return the same data as from traceback.format_exception.
|
|
|
|
"""
|
|
|
|
import traceback
|
|
|
|
frames = self.get_traceback_frames()
|
|
|
|
tb = [ (f['filename'], f['lineno'], f['function'], f['context_line']) for f in frames ]
|
|
|
|
list = ['Traceback (most recent call last):\n']
|
|
|
|
list += traceback.format_list(tb)
|
|
|
|
list += traceback.format_exception_only(self.exc_type, self.exc_value)
|
|
|
|
return list
|
2007-08-12 11:23:53 +08:00
|
|
|
|
2005-11-15 01:44:50 +08:00
|
|
|
|
|
|
|
def technical_404_response(request, exception):
|
2005-12-07 14:02:09 +08:00
|
|
|
"Create a technical 404 error response. The exception should be the Http404."
|
2005-11-15 01:44:50 +08:00
|
|
|
try:
|
|
|
|
tried = exception.args[0]['tried']
|
2010-03-06 02:53:07 +08:00
|
|
|
except (IndexError, TypeError, KeyError):
|
2005-11-15 01:44:50 +08:00
|
|
|
tried = []
|
2005-12-06 13:04:56 +08:00
|
|
|
else:
|
|
|
|
if not tried:
|
|
|
|
# tried exists but is an empty list. The URLconf must've been empty.
|
2005-12-07 14:02:09 +08:00
|
|
|
return empty_urlconf(request)
|
2005-11-17 11:10:03 +08:00
|
|
|
|
2006-09-05 07:49:14 +08:00
|
|
|
t = Template(TECHNICAL_404_TEMPLATE, name='Technical 404 template')
|
2005-11-15 01:44:50 +08:00
|
|
|
c = Context({
|
2005-11-24 07:10:17 +08:00
|
|
|
'root_urlconf': settings.ROOT_URLCONF,
|
2008-08-28 03:59:29 +08:00
|
|
|
'request_path': request.path_info[1:], # Trim leading slash
|
2005-11-24 07:10:17 +08:00
|
|
|
'urlpatterns': tried,
|
2008-08-26 06:47:07 +08:00
|
|
|
'reason': smart_str(exception, errors='replace'),
|
2005-11-24 07:10:17 +08:00
|
|
|
'request': request,
|
2005-12-07 14:02:09 +08:00
|
|
|
'settings': get_safe_settings(),
|
|
|
|
})
|
2007-06-22 15:15:04 +08:00
|
|
|
return HttpResponseNotFound(t.render(c), mimetype='text/html')
|
2005-12-07 14:02:09 +08:00
|
|
|
|
|
|
|
def empty_urlconf(request):
|
|
|
|
"Create an empty URLconf 404 error response."
|
2006-09-05 07:49:14 +08:00
|
|
|
t = Template(EMPTY_URLCONF_TEMPLATE, name='Empty URLConf template')
|
2005-12-07 14:02:09 +08:00
|
|
|
c = Context({
|
|
|
|
'project_name': settings.SETTINGS_MODULE.split('.')[0]
|
2005-11-15 01:44:50 +08:00
|
|
|
})
|
2008-03-19 06:21:04 +08:00
|
|
|
return HttpResponse(t.render(c), mimetype='text/html')
|
2005-11-15 01:44:50 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# Templates are embedded in the file so that we know the error handler will
|
|
|
|
# always work even if the template loader is broken.
|
|
|
|
#
|
|
|
|
|
|
|
|
TECHNICAL_500_TEMPLATE = """
|
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2007-12-04 14:39:05 +08:00
|
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
|
|
|
<meta name="robots" content="NONE,NOARCHIVE">
|
2008-08-28 03:59:29 +08:00
|
|
|
<title>{{ exception_type }} at {{ request.path_info|escape }}</title>
|
2005-11-15 01:44:50 +08:00
|
|
|
<style type="text/css">
|
|
|
|
html * { padding:0; margin:0; }
|
|
|
|
body * { padding:10px 20px; }
|
|
|
|
body * * { padding:0; }
|
|
|
|
body { font:small sans-serif; }
|
|
|
|
body>div { border-bottom:1px solid #ddd; }
|
|
|
|
h1 { font-weight:normal; }
|
|
|
|
h2 { margin-bottom:.8em; }
|
|
|
|
h2 span { font-size:80%; color:#666; font-weight:normal; }
|
|
|
|
h3 { margin:1em 0 .5em 0; }
|
|
|
|
h4 { margin:0 0 .5em 0; font-weight: normal; }
|
|
|
|
table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; }
|
|
|
|
tbody td, tbody th { vertical-align:top; padding:2px 3px; }
|
|
|
|
thead th { padding:1px 6px 1px 3px; background:#fefefe; text-align:left; font-weight:normal; font-size:11px; border:1px solid #ddd; }
|
|
|
|
tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; }
|
|
|
|
table.vars { margin:5px 0 2px 40px; }
|
|
|
|
table.vars td, table.req td { font-family:monospace; }
|
|
|
|
table td.code { width:100%; }
|
|
|
|
table td.code div { overflow:hidden; }
|
2005-11-24 07:12:24 +08:00
|
|
|
table.source th { color:#666; }
|
|
|
|
table.source td { font-family:monospace; white-space:pre; border-bottom:1px solid #eee; }
|
2005-11-15 01:44:50 +08:00
|
|
|
ul.traceback { list-style-type:none; }
|
|
|
|
ul.traceback li.frame { margin-bottom:1em; }
|
|
|
|
div.context { margin: 10px 0; }
|
|
|
|
div.context ol { padding-left:30px; margin:0 10px; list-style-position: inside; }
|
2005-11-17 23:27:19 +08:00
|
|
|
div.context ol li { font-family:monospace; white-space:pre; color:#666; cursor:pointer; }
|
|
|
|
div.context ol.context-line li { color:black; background-color:#ccc; }
|
|
|
|
div.context ol.context-line li span { float: right; }
|
2005-11-15 01:44:50 +08:00
|
|
|
div.commands { margin-left: 40px; }
|
|
|
|
div.commands a { color:black; text-decoration:none; }
|
|
|
|
#summary { background: #ffc; }
|
|
|
|
#summary h2 { font-weight: normal; color: #666; }
|
|
|
|
#explanation { background:#eee; }
|
2005-11-25 05:15:51 +08:00
|
|
|
#template, #template-not-exist { background:#f6f6f6; }
|
|
|
|
#template-not-exist ul { margin: 0 0 0 20px; }
|
2007-08-12 11:23:53 +08:00
|
|
|
#unicode-hint { background:#eee; }
|
2005-11-15 01:44:50 +08:00
|
|
|
#traceback { background:#eee; }
|
|
|
|
#requestinfo { background:#f6f6f6; padding-left:120px; }
|
|
|
|
#summary table { border:none; background:transparent; }
|
|
|
|
#requestinfo h2, #requestinfo h3 { position:relative; margin-left:-100px; }
|
|
|
|
#requestinfo h3 { margin-bottom:-1em; }
|
2005-11-24 07:10:17 +08:00
|
|
|
.error { background: #ffc; }
|
2005-11-24 07:12:24 +08:00
|
|
|
.specific { color:#cc3300; font-weight:bold; }
|
2007-12-02 08:00:36 +08:00
|
|
|
h2 span.commands { font-size:.7em;}
|
|
|
|
span.commands a:link {color:#5E5694;}
|
2008-08-16 20:33:36 +08:00
|
|
|
pre.exception_value { font-family: sans-serif; color: #666; font-size: 1.5em; margin: 10px 0 10px 0; }
|
2005-11-15 01:44:50 +08:00
|
|
|
</style>
|
|
|
|
<script type="text/javascript">
|
2005-11-17 22:19:33 +08:00
|
|
|
//<!--
|
2005-11-15 01:44:50 +08:00
|
|
|
function getElementsByClassName(oElm, strTagName, strClassName){
|
|
|
|
// Written by Jonathan Snook, http://www.snook.ca/jon; Add-ons by Robert Nyman, http://www.robertnyman.com
|
2005-11-17 11:10:03 +08:00
|
|
|
var arrElements = (strTagName == "*" && document.all)? document.all :
|
2005-11-15 01:44:50 +08:00
|
|
|
oElm.getElementsByTagName(strTagName);
|
|
|
|
var arrReturnElements = new Array();
|
|
|
|
strClassName = strClassName.replace(/\-/g, "\\-");
|
|
|
|
var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
|
|
|
|
var oElement;
|
|
|
|
for(var i=0; i<arrElements.length; i++){
|
2005-11-17 11:10:03 +08:00
|
|
|
oElement = arrElements[i];
|
2005-11-15 01:44:50 +08:00
|
|
|
if(oRegExp.test(oElement.className)){
|
|
|
|
arrReturnElements.push(oElement);
|
2005-11-17 11:10:03 +08:00
|
|
|
}
|
2005-11-15 01:44:50 +08:00
|
|
|
}
|
|
|
|
return (arrReturnElements)
|
|
|
|
}
|
|
|
|
function hideAll(elems) {
|
2005-11-17 11:10:03 +08:00
|
|
|
for (var e = 0; e < elems.length; e++) {
|
|
|
|
elems[e].style.display = 'none';
|
2005-11-15 01:44:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
window.onload = function() {
|
|
|
|
hideAll(getElementsByClassName(document, 'table', 'vars'));
|
|
|
|
hideAll(getElementsByClassName(document, 'ol', 'pre-context'));
|
|
|
|
hideAll(getElementsByClassName(document, 'ol', 'post-context'));
|
2006-02-28 23:52:57 +08:00
|
|
|
hideAll(getElementsByClassName(document, 'div', 'pastebin'));
|
2005-11-15 01:44:50 +08:00
|
|
|
}
|
|
|
|
function toggle() {
|
|
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
|
|
var e = document.getElementById(arguments[i]);
|
|
|
|
if (e) {
|
|
|
|
e.style.display = e.style.display == 'none' ? 'block' : 'none';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
function varToggle(link, id) {
|
|
|
|
toggle('v' + id);
|
|
|
|
var s = link.getElementsByTagName('span')[0];
|
2005-11-17 11:10:03 +08:00
|
|
|
var uarr = String.fromCharCode(0x25b6);
|
|
|
|
var darr = String.fromCharCode(0x25bc);
|
2005-11-15 01:44:50 +08:00
|
|
|
s.innerHTML = s.innerHTML == uarr ? darr : uarr;
|
|
|
|
return false;
|
|
|
|
}
|
2006-02-28 23:52:57 +08:00
|
|
|
function switchPastebinFriendly(link) {
|
|
|
|
s1 = "Switch to copy-and-paste view";
|
|
|
|
s2 = "Switch back to interactive view";
|
|
|
|
link.innerHTML = link.innerHTML == s1 ? s2 : s1;
|
|
|
|
toggle('browserTraceback', 'pastebinTraceback');
|
|
|
|
return false;
|
|
|
|
}
|
2005-11-17 22:19:33 +08:00
|
|
|
//-->
|
2005-11-15 01:44:50 +08:00
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="summary">
|
2008-08-28 03:59:29 +08:00
|
|
|
<h1>{{ exception_type }} at {{ request.path_info|escape }}</h1>
|
2010-09-11 10:02:20 +08:00
|
|
|
<pre class="exception_value">{{ exception_value|force_escape }}</pre>
|
2005-11-15 01:44:50 +08:00
|
|
|
<table class="meta">
|
|
|
|
<tr>
|
|
|
|
<th>Request Method:</th>
|
|
|
|
<td>{{ request.META.REQUEST_METHOD }}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Request URL:</th>
|
2009-04-12 10:23:19 +08:00
|
|
|
<td>{{ request.build_absolute_uri|escape }}</td>
|
2005-11-15 01:44:50 +08:00
|
|
|
</tr>
|
2010-02-25 03:39:04 +08:00
|
|
|
<tr>
|
|
|
|
<th>Django Version:</th>
|
|
|
|
<td>{{ django_version_info }}</td>
|
|
|
|
</tr>
|
2005-11-15 01:44:50 +08:00
|
|
|
<tr>
|
|
|
|
<th>Exception Type:</th>
|
|
|
|
<td>{{ exception_type }}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Exception Value:</th>
|
2010-09-11 10:02:20 +08:00
|
|
|
<td><pre>{{ exception_value|force_escape }}</pre></td>
|
2005-11-15 01:44:50 +08:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Exception Location:</th>
|
2007-04-21 12:37:31 +08:00
|
|
|
<td>{{ lastframe.filename|escape }} in {{ lastframe.function|escape }}, line {{ lastframe.lineno }}</td>
|
2005-11-15 01:44:50 +08:00
|
|
|
</tr>
|
2007-06-10 12:02:29 +08:00
|
|
|
<tr>
|
|
|
|
<th>Python Executable:</th>
|
|
|
|
<td>{{ sys_executable|escape }}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Python Version:</th>
|
|
|
|
<td>{{ sys_version_info }}</td>
|
|
|
|
</tr>
|
2007-12-11 13:22:11 +08:00
|
|
|
<tr>
|
|
|
|
<th>Python Path:</th>
|
|
|
|
<td>{{ sys_path }}</td>
|
|
|
|
</tr>
|
2008-03-20 15:01:26 +08:00
|
|
|
<tr>
|
|
|
|
<th>Server time:</th>
|
|
|
|
<td>{{server_time|date:"r"}}</td>
|
|
|
|
</tr>
|
2005-11-15 01:44:50 +08:00
|
|
|
</table>
|
|
|
|
</div>
|
2007-08-12 11:23:53 +08:00
|
|
|
{% if unicode_hint %}
|
|
|
|
<div id="unicode-hint">
|
|
|
|
<h2>Unicode error hint</h2>
|
2010-09-11 10:02:20 +08:00
|
|
|
<p>The string that could not be encoded/decoded was: <strong>{{ unicode_hint|force_escape }}</strong></p>
|
2007-08-12 11:23:53 +08:00
|
|
|
</div>
|
|
|
|
{% endif %}
|
2005-11-25 05:15:51 +08:00
|
|
|
{% if template_does_not_exist %}
|
|
|
|
<div id="template-not-exist">
|
|
|
|
<h2>Template-loader postmortem</h2>
|
|
|
|
{% if loader_debug_info %}
|
|
|
|
<p>Django tried loading these templates, in this order:</p>
|
|
|
|
<ul>
|
|
|
|
{% for loader in loader_debug_info %}
|
|
|
|
<li>Using loader <code>{{ loader.loader }}</code>:
|
|
|
|
<ul>{% for t in loader.templates %}<li><code>{{ t.name }}</code> (File {% if t.exists %}exists{% else %}does not exist{% endif %})</li>{% endfor %}</ul>
|
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% else %}
|
|
|
|
<p>Django couldn't find any templates because your <code>TEMPLATE_LOADERS</code> setting is empty!</p>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2005-11-24 07:10:17 +08:00
|
|
|
{% if template_info %}
|
|
|
|
<div id="template">
|
2005-11-24 07:15:52 +08:00
|
|
|
<h2>Template error</h2>
|
|
|
|
<p>In template <code>{{ template_info.name }}</code>, error at line <strong>{{ template_info.line }}</strong></p>
|
2007-11-14 20:58:53 +08:00
|
|
|
<h3>{{ template_info.message }}</h3>
|
2005-11-24 07:10:17 +08:00
|
|
|
<table class="source{% if template_info.top %} cut-top{% endif %}{% ifnotequal template_info.bottom template_info.total %} cut-bottom{% endifnotequal %}">
|
|
|
|
{% for source_line in template_info.source_lines %}
|
|
|
|
{% ifequal source_line.0 template_info.line %}
|
2005-11-24 07:15:52 +08:00
|
|
|
<tr class="error"><th>{{ source_line.0 }}</th>
|
2005-11-24 07:10:17 +08:00
|
|
|
<td>{{ template_info.before }}<span class="specific">{{ template_info.during }}</span>{{ template_info.after }}</td></tr>
|
|
|
|
{% else %}
|
2005-11-24 07:15:52 +08:00
|
|
|
<tr><th>{{ source_line.0 }}</th>
|
2005-11-25 08:04:06 +08:00
|
|
|
<td>{{ source_line.1 }}</td></tr>
|
2005-11-24 07:10:17 +08:00
|
|
|
{% endifequal %}
|
|
|
|
{% endfor %}
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2005-11-15 01:44:50 +08:00
|
|
|
<div id="traceback">
|
2007-12-02 08:00:36 +08:00
|
|
|
<h2>Traceback <span class="commands"><a href="#" onclick="return switchPastebinFriendly(this);">Switch to copy-and-paste view</a></span></h2>
|
2007-11-14 20:58:53 +08:00
|
|
|
{% autoescape off %}
|
2006-02-28 23:52:57 +08:00
|
|
|
<div id="browserTraceback">
|
|
|
|
<ul class="traceback">
|
|
|
|
{% for frame in frames %}
|
|
|
|
<li class="frame">
|
2007-04-21 12:37:31 +08:00
|
|
|
<code>{{ frame.filename|escape }}</code> in <code>{{ frame.function|escape }}</code>
|
2005-11-17 11:10:03 +08:00
|
|
|
|
2006-02-28 23:52:57 +08:00
|
|
|
{% if frame.context_line %}
|
|
|
|
<div class="context" id="c{{ frame.id }}">
|
|
|
|
{% if frame.pre_context %}
|
2008-07-08 09:49:50 +08:00
|
|
|
<ol start="{{ frame.pre_context_lineno }}" class="pre-context" id="pre{{ frame.id }}">{% for line in frame.pre_context %}<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ line|escape }}</li>{% endfor %}</ol>
|
2006-02-28 23:52:57 +08:00
|
|
|
{% endif %}
|
2007-11-20 09:37:16 +08:00
|
|
|
<ol start="{{ frame.lineno }}" class="context-line"><li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ frame.context_line|escape }} <span>...</span></li></ol>
|
2006-02-28 23:52:57 +08:00
|
|
|
{% if frame.post_context %}
|
2008-07-08 09:49:50 +08:00
|
|
|
<ol start='{{ frame.lineno|add:"1" }}' class="post-context" id="post{{ frame.id }}">{% for line in frame.post_context %}<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ line|escape }}</li>{% endfor %}</ol>
|
2006-02-28 23:52:57 +08:00
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2005-11-17 11:10:03 +08:00
|
|
|
|
2006-02-28 23:52:57 +08:00
|
|
|
{% if frame.vars %}
|
|
|
|
<div class="commands">
|
|
|
|
<a href="#" onclick="return varToggle(this, '{{ frame.id }}')"><span>▶</span> Local vars</a>
|
|
|
|
</div>
|
|
|
|
<table class="vars" id="v{{ frame.id }}">
|
|
|
|
<thead>
|
2005-11-15 01:44:50 +08:00
|
|
|
<tr>
|
2006-02-28 23:52:57 +08:00
|
|
|
<th>Variable</th>
|
|
|
|
<th>Value</th>
|
2005-11-15 01:44:50 +08:00
|
|
|
</tr>
|
2006-02-28 23:52:57 +08:00
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for var in frame.vars|dictsort:"0" %}
|
|
|
|
<tr>
|
2010-09-11 10:02:20 +08:00
|
|
|
<td>{{ var.0|force_escape }}</td>
|
|
|
|
<td class="code"><div>{{ var.1|pprint|force_escape }}</div></td>
|
2006-02-28 23:52:57 +08:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
{% endif %}
|
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
</div>
|
2007-12-02 08:00:36 +08:00
|
|
|
{% endautoescape %}
|
|
|
|
<form action="http://dpaste.com/" name="pasteform" id="pasteform" method="post">
|
2006-02-28 23:52:57 +08:00
|
|
|
<div id="pastebinTraceback" class="pastebin">
|
2007-12-04 14:39:05 +08:00
|
|
|
<input type="hidden" name="language" value="PythonConsole">
|
2008-08-28 03:59:29 +08:00
|
|
|
<input type="hidden" name="title" value="{{ exception_type|escape }} at {{ request.path_info|escape }}">
|
2007-12-04 14:39:05 +08:00
|
|
|
<input type="hidden" name="source" value="Django Dpaste Agent">
|
|
|
|
<input type="hidden" name="poster" value="Django">
|
2007-12-02 08:00:36 +08:00
|
|
|
<textarea name="content" id="traceback_area" cols="140" rows="25">
|
|
|
|
Environment:
|
|
|
|
|
|
|
|
Request Method: {{ request.META.REQUEST_METHOD }}
|
2009-04-12 10:23:19 +08:00
|
|
|
Request URL: {{ request.build_absolute_uri|escape }}
|
2007-12-02 08:00:36 +08:00
|
|
|
Django Version: {{ django_version_info }}
|
|
|
|
Python Version: {{ sys_version_info }}
|
2007-12-11 13:38:34 +08:00
|
|
|
Installed Applications:
|
2007-12-11 13:39:54 +08:00
|
|
|
{{ settings.INSTALLED_APPS|pprint }}
|
2007-12-11 13:38:34 +08:00
|
|
|
Installed Middleware:
|
2007-12-11 13:39:54 +08:00
|
|
|
{{ settings.MIDDLEWARE_CLASSES|pprint }}
|
2007-12-02 08:00:36 +08:00
|
|
|
|
|
|
|
{% if template_does_not_exist %}Template Loader Error:
|
|
|
|
{% if loader_debug_info %}Django tried loading these templates, in this order:
|
|
|
|
{% for loader in loader_debug_info %}Using loader {{ loader.loader }}:
|
|
|
|
{% for t in loader.templates %}{{ t.name }} (File {% if t.exists %}exists{% else %}does not exist{% endif %})
|
|
|
|
{% endfor %}{% endfor %}
|
|
|
|
{% else %}Django couldn't find any templates because your TEMPLATE_LOADERS setting is empty!
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}{% if template_info %}
|
|
|
|
Template error:
|
|
|
|
In template {{ template_info.name }}, error at line {{ template_info.line }}
|
|
|
|
{{ template_info.message }}{% for source_line in template_info.source_lines %}{% ifequal source_line.0 template_info.line %}
|
|
|
|
{{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }}
|
|
|
|
{% else %}
|
|
|
|
{{ source_line.0 }} : {{ source_line.1 }}
|
|
|
|
{% endifequal %}{% endfor %}{% endif %}
|
|
|
|
Traceback:
|
|
|
|
{% for frame in frames %}File "{{ frame.filename|escape }}" in {{ frame.function|escape }}
|
|
|
|
{% if frame.context_line %} {{ frame.lineno }}. {{ frame.context_line|escape }}{% endif %}
|
|
|
|
{% endfor %}
|
2008-08-28 03:59:29 +08:00
|
|
|
Exception Type: {{ exception_type|escape }} at {{ request.path_info|escape }}
|
2010-09-11 10:02:20 +08:00
|
|
|
Exception Value: {{ exception_value|force_escape }}
|
2007-12-02 08:00:36 +08:00
|
|
|
</textarea>
|
2007-12-04 14:39:05 +08:00
|
|
|
<br><br>
|
2007-12-24 06:53:30 +08:00
|
|
|
<input type="submit" value="Share this traceback on a public Web site">
|
2006-02-28 23:52:57 +08:00
|
|
|
</div>
|
2007-12-02 08:00:36 +08:00
|
|
|
</form>
|
2005-11-15 01:44:50 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="requestinfo">
|
|
|
|
<h2>Request information</h2>
|
2005-11-17 11:10:03 +08:00
|
|
|
|
2005-11-15 01:44:50 +08:00
|
|
|
<h3 id="get-info">GET</h3>
|
|
|
|
{% if request.GET %}
|
|
|
|
<table class="req">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Variable</th>
|
|
|
|
<th>Value</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
2005-11-17 22:19:33 +08:00
|
|
|
<tbody>
|
2005-11-15 01:44:50 +08:00
|
|
|
{% for var in request.GET.items %}
|
|
|
|
<tr>
|
|
|
|
<td>{{ var.0 }}</td>
|
2007-11-14 20:58:53 +08:00
|
|
|
<td class="code"><div>{{ var.1|pprint }}</div></td>
|
2005-11-15 01:44:50 +08:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
{% else %}
|
2005-11-17 22:19:33 +08:00
|
|
|
<p>No GET data</p>
|
2005-11-15 01:44:50 +08:00
|
|
|
{% endif %}
|
2005-11-17 11:10:03 +08:00
|
|
|
|
2005-11-15 01:44:50 +08:00
|
|
|
<h3 id="post-info">POST</h3>
|
|
|
|
{% if request.POST %}
|
|
|
|
<table class="req">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Variable</th>
|
|
|
|
<th>Value</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
2005-11-17 22:19:33 +08:00
|
|
|
<tbody>
|
2005-11-15 01:44:50 +08:00
|
|
|
{% for var in request.POST.items %}
|
|
|
|
<tr>
|
|
|
|
<td>{{ var.0 }}</td>
|
2007-11-14 20:58:53 +08:00
|
|
|
<td class="code"><div>{{ var.1|pprint }}</div></td>
|
2005-11-15 01:44:50 +08:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
{% else %}
|
2005-11-17 22:19:33 +08:00
|
|
|
<p>No POST data</p>
|
2005-11-15 01:44:50 +08:00
|
|
|
{% endif %}
|
2009-04-01 01:10:06 +08:00
|
|
|
<h3 id="files-info">FILES</h3>
|
|
|
|
{% if request.FILES %}
|
|
|
|
<table class="req">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Variable</th>
|
|
|
|
<th>Value</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for var in request.FILES.items %}
|
|
|
|
<tr>
|
|
|
|
<td>{{ var.0 }}</td>
|
|
|
|
<td class="code"><div>{{ var.1|pprint }}</div></td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
{% else %}
|
|
|
|
<p>No FILES data</p>
|
|
|
|
{% endif %}
|
2009-07-21 09:50:06 +08:00
|
|
|
|
2005-11-17 11:10:03 +08:00
|
|
|
|
2005-11-15 01:44:50 +08:00
|
|
|
<h3 id="cookie-info">COOKIES</h3>
|
|
|
|
{% if request.COOKIES %}
|
|
|
|
<table class="req">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Variable</th>
|
|
|
|
<th>Value</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
2005-11-17 22:19:33 +08:00
|
|
|
<tbody>
|
2005-11-15 01:44:50 +08:00
|
|
|
{% for var in request.COOKIES.items %}
|
|
|
|
<tr>
|
|
|
|
<td>{{ var.0 }}</td>
|
2007-11-14 20:58:53 +08:00
|
|
|
<td class="code"><div>{{ var.1|pprint }}</div></td>
|
2005-11-15 01:44:50 +08:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
{% else %}
|
2005-11-17 22:19:33 +08:00
|
|
|
<p>No cookie data</p>
|
2005-11-15 01:44:50 +08:00
|
|
|
{% endif %}
|
2005-11-17 11:10:03 +08:00
|
|
|
|
2005-11-15 01:44:50 +08:00
|
|
|
<h3 id="meta-info">META</h3>
|
|
|
|
<table class="req">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Variable</th>
|
|
|
|
<th>Value</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
2005-11-17 22:19:33 +08:00
|
|
|
<tbody>
|
2005-11-15 01:44:50 +08:00
|
|
|
{% for var in request.META.items|dictsort:"0" %}
|
|
|
|
<tr>
|
|
|
|
<td>{{ var.0 }}</td>
|
2007-11-14 20:58:53 +08:00
|
|
|
<td class="code"><div>{{ var.1|pprint }}</div></td>
|
2005-11-15 01:44:50 +08:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<h3 id="settings-info">Settings</h3>
|
|
|
|
<h4>Using settings module <code>{{ settings.SETTINGS_MODULE }}</code></h4>
|
|
|
|
<table class="req">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Setting</th>
|
|
|
|
<th>Value</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
2005-11-17 22:19:33 +08:00
|
|
|
<tbody>
|
2005-11-15 01:44:50 +08:00
|
|
|
{% for var in settings.items|dictsort:"0" %}
|
|
|
|
<tr>
|
|
|
|
<td>{{ var.0 }}</td>
|
2007-11-14 20:58:53 +08:00
|
|
|
<td class="code"><div>{{ var.1|pprint }}</div></td>
|
2005-11-15 01:44:50 +08:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="explanation">
|
|
|
|
<p>
|
|
|
|
You're seeing this error because you have <code>DEBUG = True</code> in your
|
|
|
|
Django settings file. Change that to <code>False</code>, and Django will
|
|
|
|
display a standard 500 page.
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
"""
|
|
|
|
|
|
|
|
TECHNICAL_404_TEMPLATE = """
|
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2007-12-04 14:39:05 +08:00
|
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
2008-08-28 03:59:29 +08:00
|
|
|
<title>Page not found at {{ request.path_info|escape }}</title>
|
2007-12-04 14:39:05 +08:00
|
|
|
<meta name="robots" content="NONE,NOARCHIVE">
|
2005-11-15 01:44:50 +08:00
|
|
|
<style type="text/css">
|
|
|
|
html * { padding:0; margin:0; }
|
|
|
|
body * { padding:10px 20px; }
|
|
|
|
body * * { padding:0; }
|
|
|
|
body { font:small sans-serif; background:#eee; }
|
|
|
|
body>div { border-bottom:1px solid #ddd; }
|
|
|
|
h1 { font-weight:normal; margin-bottom:.4em; }
|
|
|
|
h1 span { font-size:60%; color:#666; font-weight:normal; }
|
|
|
|
table { border:none; border-collapse: collapse; width:100%; }
|
|
|
|
td, th { vertical-align:top; padding:2px 3px; }
|
|
|
|
th { width:12em; text-align:right; color:#666; padding-right:.5em; }
|
|
|
|
#info { background:#f6f6f6; }
|
|
|
|
#info ol { margin: 0.5em 4em; }
|
|
|
|
#info ol li { font-family: monospace; }
|
|
|
|
#summary { background: #ffc; }
|
|
|
|
#explanation { background:#eee; border-bottom: 0px none; }
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="summary">
|
|
|
|
<h1>Page not found <span>(404)</span></h1>
|
|
|
|
<table class="meta">
|
|
|
|
<tr>
|
|
|
|
<th>Request Method:</th>
|
|
|
|
<td>{{ request.META.REQUEST_METHOD }}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Request URL:</th>
|
2009-04-12 10:23:19 +08:00
|
|
|
<td>{{ request.build_absolute_uri|escape }}</td>
|
2005-11-15 01:44:50 +08:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div id="info">
|
2005-12-07 14:02:09 +08:00
|
|
|
{% if urlpatterns %}
|
|
|
|
<p>
|
|
|
|
Using the URLconf defined in <code>{{ settings.ROOT_URLCONF }}</code>,
|
|
|
|
Django tried these URL patterns, in this order:
|
|
|
|
</p>
|
|
|
|
<ol>
|
|
|
|
{% for pattern in urlpatterns %}
|
2010-09-13 03:27:33 +08:00
|
|
|
<li>
|
|
|
|
{% for pat in pattern %}
|
|
|
|
{{ pat.regex.pattern }}
|
|
|
|
{% if forloop.last and pat.name %}[name='{{ pat.name }}']{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
</li>
|
2005-12-07 14:02:09 +08:00
|
|
|
{% endfor %}
|
|
|
|
</ol>
|
2007-04-09 09:10:26 +08:00
|
|
|
<p>The current URL, <code>{{ request_path|escape }}</code>, didn't match any of these.</p>
|
2005-12-06 13:04:56 +08:00
|
|
|
{% else %}
|
2007-11-14 20:58:53 +08:00
|
|
|
<p>{{ reason }}</p>
|
2005-11-15 01:44:50 +08:00
|
|
|
{% endif %}
|
|
|
|
</div>
|
2005-11-17 11:10:03 +08:00
|
|
|
|
2005-11-15 01:44:50 +08:00
|
|
|
<div id="explanation">
|
|
|
|
<p>
|
|
|
|
You're seeing this error because you have <code>DEBUG = True</code> in
|
|
|
|
your Django settings file. Change that to <code>False</code>, and Django
|
|
|
|
will display a standard 404 page.
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|
2005-11-24 08:06:36 +08:00
|
|
|
"""
|
2005-12-07 14:02:09 +08:00
|
|
|
|
|
|
|
EMPTY_URLCONF_TEMPLATE = """
|
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
|
|
<html lang="en"><head>
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
|
|
|
<meta name="robots" content="NONE,NOARCHIVE"><title>Welcome to Django</title>
|
|
|
|
<style type="text/css">
|
|
|
|
html * { padding:0; margin:0; }
|
|
|
|
body * { padding:10px 20px; }
|
|
|
|
body * * { padding:0; }
|
|
|
|
body { font:small sans-serif; }
|
|
|
|
body>div { border-bottom:1px solid #ddd; }
|
|
|
|
h1 { font-weight:normal; }
|
|
|
|
h2 { margin-bottom:.8em; }
|
|
|
|
h2 span { font-size:80%; color:#666; font-weight:normal; }
|
|
|
|
h3 { margin:1em 0 .5em 0; }
|
|
|
|
h4 { margin:0 0 .5em 0; font-weight: normal; }
|
|
|
|
table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; }
|
|
|
|
tbody td, tbody th { vertical-align:top; padding:2px 3px; }
|
|
|
|
thead th { padding:1px 6px 1px 3px; background:#fefefe; text-align:left; font-weight:normal; font-size:11px; border:1px solid #ddd; }
|
|
|
|
tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; }
|
|
|
|
ul { margin-left: 2em; margin-top: 1em; }
|
|
|
|
#summary { background: #e0ebff; }
|
|
|
|
#summary h2 { font-weight: normal; color: #666; }
|
|
|
|
#explanation { background:#eee; }
|
|
|
|
#instructions { background:#f6f6f6; }
|
|
|
|
#summary table { border:none; background:transparent; }
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<div id="summary">
|
|
|
|
<h1>It worked!</h1>
|
|
|
|
<h2>Congratulations on your first Django-powered page.</h2>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="instructions">
|
|
|
|
<p>Of course, you haven't actually done any work yet. Here's what to do next:</p>
|
|
|
|
<ul>
|
2009-12-22 23:18:51 +08:00
|
|
|
<li>If you plan to use a database, edit the <code>DATABASES</code> setting in <code>{{ project_name }}/settings.py</code>.</li>
|
2006-05-02 09:31:56 +08:00
|
|
|
<li>Start your first app by running <code>python {{ project_name }}/manage.py startapp [appname]</code>.</li>
|
2005-12-07 14:02:09 +08:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="explanation">
|
|
|
|
<p>
|
|
|
|
You're seeing this message because you have <code>DEBUG = True</code> in your
|
|
|
|
Django settings file and you haven't configured any URLs. Get to work!
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</body></html>
|
|
|
|
"""
|