2005-11-15 01:44:50 +08:00
|
|
|
from django.conf import settings
|
2006-05-02 09:31:56 +08:00
|
|
|
from django.template import Template, Context, TemplateDoesNotExist
|
2005-11-24 07:10:17 +08:00
|
|
|
from django.utils.html import escape
|
2006-05-02 09:31:56 +08:00
|
|
|
from django.http import HttpResponseServerError, HttpResponseNotFound
|
2006-01-19 09:06:12 +08:00
|
|
|
import os, re
|
2005-11-15 01:44:50 +08:00
|
|
|
|
2005-11-15 22:35:24 +08:00
|
|
|
HIDDEN_SETTINGS = re.compile('SECRET|PASSWORD')
|
|
|
|
|
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
|
|
|
|
|
|
|
|
def get_template_exception_info(exc_type, exc_value, tb):
|
|
|
|
origin, (start, end) = exc_value.source
|
|
|
|
template_source = origin.reload()
|
|
|
|
context_lines = 10
|
|
|
|
line = 0
|
|
|
|
upto = 0
|
|
|
|
source_lines = []
|
2005-12-09 10:35:38 +08:00
|
|
|
before = during = after = ""
|
2005-11-25 08:04:06 +08:00
|
|
|
for num, next in enumerate(linebreak_iter(template_source)):
|
2005-11-24 07:10:17 +08:00
|
|
|
if start >= upto and end <= next:
|
|
|
|
line = num
|
2005-11-25 08:04:06 +08:00
|
|
|
before = escape(template_source[upto:start])
|
2005-11-24 07:10:17 +08:00
|
|
|
during = escape(template_source[start:end])
|
2005-11-25 06:57:04 +08:00
|
|
|
after = escape(template_source[end:next])
|
2005-11-25 08:04:06 +08:00
|
|
|
source_lines.append( (num, escape(template_source[upto:next])) )
|
2005-11-24 07:10:17 +08:00
|
|
|
upto = next
|
|
|
|
total = len(source_lines)
|
|
|
|
|
2005-11-25 08:04:06 +08:00
|
|
|
top = max(1, line - context_lines)
|
2005-11-24 07:10:17 +08:00
|
|
|
bottom = min(total, line + 1 + context_lines)
|
|
|
|
|
|
|
|
template_info = {
|
|
|
|
'message': exc_value.args[0],
|
|
|
|
'source_lines': source_lines[top:bottom],
|
|
|
|
'before': before,
|
|
|
|
'during': during,
|
|
|
|
'after': after,
|
2005-11-25 05:15:51 +08:00
|
|
|
'top': top,
|
|
|
|
'bottom': bottom,
|
2005-11-24 07:10:17 +08:00
|
|
|
'total': total,
|
|
|
|
'line': line,
|
|
|
|
'name': origin.name,
|
|
|
|
}
|
|
|
|
exc_info = hasattr(exc_value, 'exc_info') and exc_value.exc_info or (exc_type, exc_value, tb)
|
|
|
|
return exc_info + (template_info,)
|
|
|
|
|
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():
|
|
|
|
if HIDDEN_SETTINGS.search(k):
|
|
|
|
settings_dict[k] = '********************'
|
|
|
|
else:
|
|
|
|
settings_dict[k] = getattr(settings, k)
|
|
|
|
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.
|
|
|
|
"""
|
2005-11-24 07:10:17 +08:00
|
|
|
template_info = None
|
2005-11-25 05:15:51 +08:00
|
|
|
template_does_not_exist = False
|
|
|
|
loader_debug_info = None
|
|
|
|
if issubclass(exc_type, TemplateDoesNotExist):
|
2006-05-02 09:31:56 +08:00
|
|
|
from django.template.loader import template_source_loaders
|
2005-11-25 05:15:51 +08:00
|
|
|
template_does_not_exist = True
|
|
|
|
loader_debug_info = []
|
|
|
|
for loader in template_source_loaders:
|
|
|
|
try:
|
|
|
|
source_list_func = getattr(__import__(loader.__module__, '', '', ['get_template_sources']), 'get_template_sources')
|
|
|
|
# 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(exc_value))]
|
|
|
|
except (ImportError, AttributeError):
|
|
|
|
template_list = []
|
|
|
|
loader_debug_info.append({
|
|
|
|
'loader': loader.__module__ + '.' + loader.__name__,
|
|
|
|
'templates': template_list,
|
|
|
|
})
|
2005-11-24 07:10:17 +08:00
|
|
|
if settings.TEMPLATE_DEBUG and hasattr(exc_value, 'source'):
|
|
|
|
exc_type, exc_value, tb, template_info = get_template_exception_info(exc_type, exc_value, tb)
|
2005-11-15 01:44:50 +08:00
|
|
|
frames = []
|
|
|
|
while tb is not None:
|
|
|
|
filename = tb.tb_frame.f_code.co_filename
|
|
|
|
function = tb.tb_frame.f_code.co_name
|
|
|
|
lineno = tb.tb_lineno - 1
|
|
|
|
pre_context_lineno, pre_context, context_line, post_context = _get_lines_from_file(filename, lineno, 7)
|
2006-05-07 07:18:22 +08:00
|
|
|
if pre_context_lineno:
|
|
|
|
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,
|
|
|
|
})
|
2005-11-15 01:44:50 +08:00
|
|
|
tb = tb.tb_next
|
2005-11-17 11:10:03 +08:00
|
|
|
|
2006-06-14 19:44:56 +08:00
|
|
|
if not frames:
|
|
|
|
frames = [{
|
|
|
|
'filename': '<unknown>',
|
|
|
|
'function': '?',
|
|
|
|
'lineno': '?',
|
|
|
|
}]
|
2006-08-27 20:35:07 +08:00
|
|
|
t = Template(TECHNICAL_500_TEMPLATE, name='Technical 500 Template')
|
2005-11-15 01:44:50 +08:00
|
|
|
c = Context({
|
2005-11-24 07:10:17 +08:00
|
|
|
'exception_type': exc_type.__name__,
|
|
|
|
'exception_value': exc_value,
|
|
|
|
'frames': frames,
|
|
|
|
'lastframe': frames[-1],
|
|
|
|
'request': request,
|
2006-07-22 00:20:22 +08:00
|
|
|
'request_protocol': request.is_secure() and "https" or "http",
|
2005-12-07 14:02:09 +08:00
|
|
|
'settings': get_safe_settings(),
|
2005-11-24 07:10:17 +08:00
|
|
|
'template_info': template_info,
|
2005-11-25 05:15:51 +08:00
|
|
|
'template_does_not_exist': template_does_not_exist,
|
|
|
|
'loader_debug_info': loader_debug_info,
|
2005-11-15 01:44:50 +08:00
|
|
|
})
|
2005-11-22 22:22:02 +08:00
|
|
|
return HttpResponseServerError(t.render(c), mimetype='text/html')
|
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']
|
|
|
|
except (IndexError, TypeError):
|
|
|
|
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-08-27 20:35:07 +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,
|
|
|
|
'urlpatterns': tried,
|
|
|
|
'reason': str(exception),
|
|
|
|
'request': request,
|
2006-07-22 00:20:22 +08:00
|
|
|
'request_protocol': request.is_secure() and "https" or "http",
|
2005-12-07 14:02:09 +08:00
|
|
|
'settings': get_safe_settings(),
|
|
|
|
})
|
|
|
|
return HttpResponseNotFound(t.render(c), mimetype='text/html')
|
|
|
|
|
|
|
|
def empty_urlconf(request):
|
|
|
|
"Create an empty URLconf 404 error response."
|
2006-08-27 20:35:07 +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
|
|
|
})
|
2005-11-22 22:22:02 +08:00
|
|
|
return HttpResponseNotFound(t.render(c), mimetype='text/html')
|
2005-11-15 01:44:50 +08:00
|
|
|
|
|
|
|
def _get_lines_from_file(filename, lineno, context_lines):
|
|
|
|
"""
|
2005-11-17 11:10:03 +08:00
|
|
|
Returns context_lines before and after lineno from file.
|
2005-11-15 01:44:50 +08:00
|
|
|
Returns (pre_context_lineno, pre_context, context_line, post_context).
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
source = open(filename).readlines()
|
|
|
|
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]]
|
2005-11-17 11:10:03 +08:00
|
|
|
|
2005-11-15 01:44:50 +08:00
|
|
|
return lower_bound, pre_context, context_line, post_context
|
|
|
|
except (OSError, IOError):
|
|
|
|
return None, [], None, []
|
|
|
|
|
|
|
|
#
|
|
|
|
# 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>
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
2005-11-15 02:50:13 +08:00
|
|
|
<meta name="robots" content="NONE,NOARCHIVE" />
|
2005-11-15 01:44:50 +08:00
|
|
|
<title>{{ exception_type }} at {{ request.path }}</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; }
|
|
|
|
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; }
|
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; }
|
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">
|
|
|
|
<h1>{{ exception_type }} at {{ request.path }}</h1>
|
2006-01-06 00:28:25 +08:00
|
|
|
<h2>{{ exception_value|escape }}</h2>
|
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>
|
|
|
|
<td>{{ request_protocol }}://{{ request.META.HTTP_HOST }}{{ request.path }}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Exception Type:</th>
|
|
|
|
<td>{{ exception_type }}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Exception Value:</th>
|
|
|
|
<td>{{ exception_value }}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th>Exception Location:</th>
|
|
|
|
<td>{{ lastframe.filename }} in {{ lastframe.function }}, line {{ lastframe.lineno }}</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
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>
|
|
|
|
<h3>{{ template_info.message|escape }}</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">
|
|
|
|
<h2>Traceback <span>(innermost last)</span></h2>
|
2006-02-28 23:52:57 +08:00
|
|
|
<div class="commands"><a href="#" onclick="return switchPastebinFriendly(this);">Switch to copy-and-paste view</a></div>
|
|
|
|
<br/>
|
|
|
|
<div id="browserTraceback">
|
|
|
|
<ul class="traceback">
|
|
|
|
{% for frame in frames %}
|
|
|
|
<li class="frame">
|
|
|
|
<code>{{ frame.filename }}</code> in <code>{{ frame.function }}</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 %}
|
2006-05-03 02:44:22 +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 %}
|
2006-05-03 02:44:22 +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 %}
|
2006-05-03 02:44:22 +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>
|
|
|
|
<td>{{ var.0 }}</td>
|
|
|
|
<td class="code"><div>{{ var.1|pprint|escape }}</div></td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
{% endif %}
|
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div id="pastebinTraceback" class="pastebin">
|
|
|
|
<table>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<code>
|
|
|
|
Traceback (most recent call last):<br/>
|
|
|
|
{% for frame in frames %}
|
|
|
|
File "{{ frame.filename }}" in {{ frame.function }}<br/>
|
|
|
|
{% if frame.context_line %}
|
2006-05-03 02:44:22 +08:00
|
|
|
{{ frame.lineno }}. {{ frame.context_line|escape }}<br/>
|
2006-02-28 23:52:57 +08:00
|
|
|
{% endif %}
|
|
|
|
{% endfor %}<br/>
|
|
|
|
{{ exception_type }} at {{ request.path }}<br/>
|
|
|
|
{{ exception_value|escape }}</code>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
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>
|
|
|
|
<td class="code"><div>{{ var.1|pprint|escape }}</div></td>
|
|
|
|
</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>
|
|
|
|
<td class="code"><div>{{ var.1|pprint|escape }}</div></td>
|
|
|
|
</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 %}
|
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>
|
|
|
|
<td class="code"><div>{{ var.1|pprint|escape }}</div></td>
|
|
|
|
</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>
|
|
|
|
<td class="code"><div>{{ var.1|pprint|escape }}</div></td>
|
|
|
|
</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>
|
|
|
|
<td class="code"><div>{{ var.1|pprint|escape }}</div></td>
|
|
|
|
</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>
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
|
|
|
<title>Page not found at {{ request.path }}</title>
|
|
|
|
<meta name="robots" content="NONE,NOARCHIVE" />
|
|
|
|
<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>
|
|
|
|
<td>{{ request_protocol }}://{{ request.META.HTTP_HOST }}{{ request.path }}</td>
|
|
|
|
</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 %}
|
|
|
|
<li>{{ pattern|escape }}</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ol>
|
|
|
|
<p>The current URL, <code>{{ request.path }}</code>, didn't match any of these.</p>
|
2005-12-06 13:04:56 +08:00
|
|
|
{% else %}
|
2005-12-07 14:02:09 +08:00
|
|
|
<p>{{ reason|escape }}</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>
|
2006-05-02 09:31:56 +08:00
|
|
|
<li>If you plan to use a database, edit the <code>DATABASE_*</code> settings in <code>{{ project_name }}/settings.py</code>.</li>
|
|
|
|
<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>
|
|
|
|
"""
|