2012-06-08 00:08:47 +08:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2010-02-25 05:58:01 +08:00
|
|
|
import datetime
|
2007-12-11 13:38:34 +08:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import sys
|
2010-12-13 06:54:04 +08:00
|
|
|
import types
|
2007-12-11 13:38:34 +08:00
|
|
|
|
2005-11-15 01:44:50 +08:00
|
|
|
from django.conf import settings
|
2015-01-11 17:06:42 +08:00
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
2014-06-16 15:39:18 +08:00
|
|
|
from django.core.urlresolvers import resolve, Resolver404
|
2014-06-24 12:13:34 +08:00
|
|
|
from django.http import (HttpResponse, HttpResponseNotFound, HttpRequest,
|
|
|
|
build_request_repr)
|
2015-01-11 17:06:42 +08:00
|
|
|
from django.template import Context, Engine, TemplateDoesNotExist
|
2011-01-13 21:47:03 +08:00
|
|
|
from django.template.defaultfilters import force_escape, pprint
|
2013-09-17 19:46:38 +08:00
|
|
|
from django.utils.datastructures import MultiValueDict
|
2005-11-24 07:10:17 +08:00
|
|
|
from django.utils.html import escape
|
2012-08-29 02:59:56 +08:00
|
|
|
from django.utils.encoding import force_bytes, smart_text
|
2014-11-19 04:52:58 +08:00
|
|
|
from django.utils import lru_cache
|
2014-01-21 04:15:14 +08:00
|
|
|
from django.utils.module_loading import import_string
|
2012-07-20 20:22:00 +08:00
|
|
|
from django.utils import six
|
2014-05-18 06:26:46 +08:00
|
|
|
from django.utils.translation import ugettext as _
|
2005-11-15 01:44:50 +08:00
|
|
|
|
2015-01-11 17:06:42 +08:00
|
|
|
|
|
|
|
# Minimal Django templates engine to render the error templates
|
|
|
|
# regardless of the project's TEMPLATES setting.
|
|
|
|
DEBUG_ENGINE = Engine(debug=True)
|
|
|
|
|
2014-03-21 19:05:36 +08:00
|
|
|
HIDDEN_SETTINGS = re.compile('API|TOKEN|KEY|SECRET|PASS|SIGNATURE')
|
2005-11-15 22:35:24 +08:00
|
|
|
|
2012-06-08 00:08:47 +08:00
|
|
|
CLEANSED_SUBSTITUTE = '********************'
|
2011-06-09 06:18:46 +08:00
|
|
|
|
2013-11-03 07:53:29 +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:
|
2013-11-04 02:08:55 +08:00
|
|
|
yield p + 1
|
|
|
|
p = template_source.find('\n', p + 1)
|
2005-11-24 07:10:17 +08:00
|
|
|
yield len(template_source) + 1
|
|
|
|
|
2013-11-03 07:53:29 +08:00
|
|
|
|
2014-07-26 18:06:48 +08:00
|
|
|
class CallableSettingWrapper(object):
|
|
|
|
""" Object to wrap callable appearing in settings
|
|
|
|
|
|
|
|
* Not to call in the debug page (#21345).
|
|
|
|
* Not to break the debug page if the callable forbidding to set attributes (#23070).
|
|
|
|
"""
|
|
|
|
def __init__(self, callable_setting):
|
|
|
|
self._wrapped = callable_setting
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return repr(self._wrapped)
|
|
|
|
|
|
|
|
|
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):
|
2011-06-09 06:18:46 +08:00
|
|
|
cleansed = CLEANSED_SUBSTITUTE
|
2010-01-31 10:30:02 +08:00
|
|
|
else:
|
2010-02-01 07:38:17 +08:00
|
|
|
if isinstance(value, dict):
|
2014-12-07 05:00:09 +08:00
|
|
|
cleansed = {k: cleanse_setting(k, v) for k, v in value.items()}
|
2010-02-01 07:38:17 +08:00
|
|
|
else:
|
|
|
|
cleansed = value
|
|
|
|
except TypeError:
|
|
|
|
# If the key isn't regex-able, just return as-is.
|
|
|
|
cleansed = value
|
2013-10-30 06:06:59 +08:00
|
|
|
|
|
|
|
if callable(cleansed):
|
2014-07-26 18:06:48 +08:00
|
|
|
# For fixing #21345 and #23070
|
|
|
|
cleansed = CallableSettingWrapper(cleansed)
|
2013-10-30 06:06:59 +08:00
|
|
|
|
2010-01-31 10:30:02 +08:00
|
|
|
return cleansed
|
|
|
|
|
2013-11-03 07:53:29 +08:00
|
|
|
|
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
|
|
|
|
|
2013-11-03 07:53:29 +08:00
|
|
|
|
2014-06-24 12:13:34 +08:00
|
|
|
def technical_500_response(request, exc_type, exc_value, tb, status_code=500):
|
2005-11-15 01:44:50 +08:00
|
|
|
"""
|
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)
|
2011-10-02 10:53:58 +08:00
|
|
|
if request.is_ajax():
|
|
|
|
text = reporter.get_traceback_text()
|
2014-06-24 12:13:34 +08:00
|
|
|
return HttpResponse(text, status=status_code, content_type='text/plain')
|
2011-10-02 10:53:58 +08:00
|
|
|
else:
|
|
|
|
html = reporter.get_traceback_html()
|
2014-06-24 12:13:34 +08:00
|
|
|
return HttpResponse(html, status=status_code, content_type='text/html')
|
2008-03-18 22:34:48 +08:00
|
|
|
|
2014-11-19 04:52:58 +08:00
|
|
|
|
|
|
|
@lru_cache.lru_cache()
|
|
|
|
def get_default_exception_reporter_filter():
|
|
|
|
# Instantiate the default filter for the first time and cache it.
|
|
|
|
return import_string(settings.DEFAULT_EXCEPTION_REPORTER_FILTER)()
|
2011-06-09 06:18:46 +08:00
|
|
|
|
2013-11-03 07:53:29 +08:00
|
|
|
|
2011-06-09 06:18:46 +08:00
|
|
|
def get_exception_reporter_filter(request):
|
2014-11-19 04:52:58 +08:00
|
|
|
default_filter = get_default_exception_reporter_filter()
|
|
|
|
return getattr(request, 'exception_reporter_filter', default_filter)
|
2011-06-09 06:18:46 +08:00
|
|
|
|
2013-11-03 07:53:29 +08:00
|
|
|
|
2011-06-09 06:18:46 +08:00
|
|
|
class ExceptionReporterFilter(object):
|
|
|
|
"""
|
|
|
|
Base for all exception reporter filter classes. All overridable hooks
|
2011-12-18 01:37:24 +08:00
|
|
|
contain lenient default behaviors.
|
2011-06-09 06:18:46 +08:00
|
|
|
"""
|
|
|
|
|
|
|
|
def get_request_repr(self, request):
|
|
|
|
if request is None:
|
|
|
|
return repr(None)
|
|
|
|
else:
|
2011-06-10 07:15:42 +08:00
|
|
|
return build_request_repr(request, POST_override=self.get_post_parameters(request))
|
2011-06-09 06:18:46 +08:00
|
|
|
|
|
|
|
def get_post_parameters(self, request):
|
|
|
|
if request is None:
|
|
|
|
return {}
|
|
|
|
else:
|
|
|
|
return request.POST
|
|
|
|
|
|
|
|
def get_traceback_frame_variables(self, request, tb_frame):
|
2012-07-21 03:14:27 +08:00
|
|
|
return list(six.iteritems(tb_frame.f_locals))
|
2011-06-09 06:18:46 +08:00
|
|
|
|
2013-11-03 07:53:29 +08:00
|
|
|
|
2011-06-09 06:18:46 +08:00
|
|
|
class SafeExceptionReporterFilter(ExceptionReporterFilter):
|
|
|
|
"""
|
|
|
|
Use annotations made by the sensitive_post_parameters and
|
|
|
|
sensitive_variables decorators to filter out sensitive information.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def is_active(self, request):
|
|
|
|
"""
|
|
|
|
This filter is to add safety in production environments (i.e. DEBUG
|
|
|
|
is False). If DEBUG is True then your site is not safe anyway.
|
|
|
|
This hook is provided as a convenience to easily activate or
|
|
|
|
deactivate the filter on a per request basis.
|
|
|
|
"""
|
|
|
|
return settings.DEBUG is False
|
|
|
|
|
2013-09-17 19:46:38 +08:00
|
|
|
def get_cleansed_multivaluedict(self, request, multivaluedict):
|
|
|
|
"""
|
|
|
|
Replaces the keys in a MultiValueDict marked as sensitive with stars.
|
|
|
|
This mitigates leaking sensitive POST parameters if something like
|
|
|
|
request.POST['nonexistent_key'] throws an exception (#21098).
|
|
|
|
"""
|
|
|
|
sensitive_post_parameters = getattr(request, 'sensitive_post_parameters', [])
|
|
|
|
if self.is_active(request) and sensitive_post_parameters:
|
|
|
|
multivaluedict = multivaluedict.copy()
|
|
|
|
for param in sensitive_post_parameters:
|
|
|
|
if param in multivaluedict:
|
|
|
|
multivaluedict[param] = CLEANSED_SUBSTITUTE
|
|
|
|
return multivaluedict
|
|
|
|
|
2011-06-09 06:18:46 +08:00
|
|
|
def get_post_parameters(self, request):
|
|
|
|
"""
|
|
|
|
Replaces the values of POST parameters marked as sensitive with
|
|
|
|
stars (*********).
|
|
|
|
"""
|
|
|
|
if request is None:
|
|
|
|
return {}
|
|
|
|
else:
|
|
|
|
sensitive_post_parameters = getattr(request, 'sensitive_post_parameters', [])
|
|
|
|
if self.is_active(request) and sensitive_post_parameters:
|
|
|
|
cleansed = request.POST.copy()
|
|
|
|
if sensitive_post_parameters == '__ALL__':
|
|
|
|
# Cleanse all parameters.
|
|
|
|
for k, v in cleansed.items():
|
|
|
|
cleansed[k] = CLEANSED_SUBSTITUTE
|
|
|
|
return cleansed
|
|
|
|
else:
|
|
|
|
# Cleanse only the specified parameters.
|
|
|
|
for param in sensitive_post_parameters:
|
2011-09-10 03:33:40 +08:00
|
|
|
if param in cleansed:
|
2011-06-09 06:18:46 +08:00
|
|
|
cleansed[param] = CLEANSED_SUBSTITUTE
|
|
|
|
return cleansed
|
|
|
|
else:
|
|
|
|
return request.POST
|
|
|
|
|
2013-09-17 19:46:38 +08:00
|
|
|
def cleanse_special_types(self, request, value):
|
|
|
|
if isinstance(value, HttpRequest):
|
|
|
|
# Cleanse the request's POST parameters.
|
|
|
|
value = self.get_request_repr(value)
|
|
|
|
elif isinstance(value, MultiValueDict):
|
|
|
|
# Cleanse MultiValueDicts (request.POST is the one we usually care about)
|
|
|
|
value = self.get_cleansed_multivaluedict(request, value)
|
|
|
|
return value
|
|
|
|
|
2011-06-09 06:18:46 +08:00
|
|
|
def get_traceback_frame_variables(self, request, tb_frame):
|
|
|
|
"""
|
|
|
|
Replaces the values of variables marked as sensitive with
|
|
|
|
stars (*********).
|
|
|
|
"""
|
2012-06-04 08:33:09 +08:00
|
|
|
# Loop through the frame's callers to see if the sensitive_variables
|
|
|
|
# decorator was used.
|
|
|
|
current_frame = tb_frame.f_back
|
|
|
|
sensitive_variables = None
|
|
|
|
while current_frame is not None:
|
|
|
|
if (current_frame.f_code.co_name == 'sensitive_variables_wrapper'
|
2013-11-26 17:43:46 +08:00
|
|
|
and 'sensitive_variables_wrapper' in current_frame.f_locals):
|
2012-06-04 08:33:09 +08:00
|
|
|
# The sensitive_variables decorator was used, so we take note
|
|
|
|
# of the sensitive variables' names.
|
|
|
|
wrapper = current_frame.f_locals['sensitive_variables_wrapper']
|
|
|
|
sensitive_variables = getattr(wrapper, 'sensitive_variables', None)
|
|
|
|
break
|
|
|
|
current_frame = current_frame.f_back
|
|
|
|
|
2013-01-01 01:34:08 +08:00
|
|
|
cleansed = {}
|
2011-06-09 06:18:46 +08:00
|
|
|
if self.is_active(request) and sensitive_variables:
|
|
|
|
if sensitive_variables == '__ALL__':
|
|
|
|
# Cleanse all variables
|
|
|
|
for name, value in tb_frame.f_locals.items():
|
2013-01-01 01:34:08 +08:00
|
|
|
cleansed[name] = CLEANSED_SUBSTITUTE
|
2011-06-09 06:18:46 +08:00
|
|
|
else:
|
|
|
|
# Cleanse specified variables
|
|
|
|
for name, value in tb_frame.f_locals.items():
|
|
|
|
if name in sensitive_variables:
|
|
|
|
value = CLEANSED_SUBSTITUTE
|
2013-09-17 19:46:38 +08:00
|
|
|
else:
|
|
|
|
value = self.cleanse_special_types(request, value)
|
2013-01-01 01:34:08 +08:00
|
|
|
cleansed[name] = value
|
2011-06-09 06:18:46 +08:00
|
|
|
else:
|
2013-09-17 19:46:38 +08:00
|
|
|
# Potentially cleanse the request and any MultiValueDicts if they
|
|
|
|
# are one of the frame variables.
|
2011-06-09 06:18:46 +08:00
|
|
|
for name, value in tb_frame.f_locals.items():
|
2013-09-17 19:46:38 +08:00
|
|
|
cleansed[name] = self.cleanse_special_types(request, value)
|
2013-01-01 01:34:08 +08:00
|
|
|
|
|
|
|
if (tb_frame.f_code.co_name == 'sensitive_variables_wrapper'
|
2013-11-26 17:43:46 +08:00
|
|
|
and 'sensitive_variables_wrapper' in tb_frame.f_locals):
|
2013-01-01 01:34:08 +08:00
|
|
|
# For good measure, obfuscate the decorated function's arguments in
|
|
|
|
# the sensitive_variables decorator's frame, in case the variables
|
|
|
|
# associated with those arguments were meant to be obfuscated from
|
|
|
|
# the decorated function's frame.
|
|
|
|
cleansed['func_args'] = CLEANSED_SUBSTITUTE
|
|
|
|
cleansed['func_kwargs'] = CLEANSED_SUBSTITUTE
|
|
|
|
|
|
|
|
return cleansed.items()
|
2011-06-09 06:18:46 +08:00
|
|
|
|
2013-11-03 07:53:29 +08:00
|
|
|
|
2011-02-01 22:18:07 +08:00
|
|
|
class ExceptionReporter(object):
|
2008-07-16 02:47:49 +08:00
|
|
|
"""
|
|
|
|
A class to organize and coordinate reporting on exceptions.
|
|
|
|
"""
|
2010-12-06 22:21:51 +08:00
|
|
|
def __init__(self, request, exc_type, exc_value, tb, is_email=False):
|
2008-07-16 02:47:49 +08:00
|
|
|
self.request = request
|
2011-06-09 06:18:46 +08:00
|
|
|
self.filter = get_exception_reporter_filter(self.request)
|
2008-07-16 02:47:49 +08:00
|
|
|
self.exc_type = exc_type
|
|
|
|
self.exc_value = exc_value
|
|
|
|
self.tb = tb
|
2010-12-06 22:21:51 +08:00
|
|
|
self.is_email = is_email
|
2008-07-16 02:47:49 +08:00
|
|
|
|
|
|
|
self.template_info = None
|
|
|
|
self.template_does_not_exist = False
|
|
|
|
self.loader_debug_info = None
|
|
|
|
|
|
|
|
# Handle deprecated string exceptions
|
2012-07-20 20:22:00 +08:00
|
|
|
if isinstance(self.exc_type, six.string_types):
|
2008-07-16 02:47:49 +08:00
|
|
|
self.exc_value = Exception('Deprecated String Exception: %r' % self.exc_type)
|
|
|
|
self.exc_type = type(self.exc_value)
|
|
|
|
|
2013-02-24 23:41:10 +08:00
|
|
|
def format_path_status(self, path):
|
|
|
|
if not os.path.exists(path):
|
|
|
|
return "File does not exist"
|
|
|
|
if not os.path.isfile(path):
|
|
|
|
return "Not a file"
|
|
|
|
if not os.access(path, os.R_OK):
|
|
|
|
return "File is not readable"
|
|
|
|
return "File exists"
|
|
|
|
|
2011-10-02 10:53:58 +08:00
|
|
|
def get_traceback_data(self):
|
2012-10-20 20:50:44 +08:00
|
|
|
"""Return a dictionary containing traceback information."""
|
2015-01-11 17:06:42 +08:00
|
|
|
try:
|
|
|
|
default_template_engine = Engine.get_default()
|
|
|
|
except ImproperlyConfigured:
|
|
|
|
default_template_engine = None
|
2008-07-16 02:47:49 +08:00
|
|
|
|
2015-01-11 17:06:42 +08:00
|
|
|
# TODO: add support for multiple template engines (#24120).
|
|
|
|
# TemplateDoesNotExist should carry all the information.
|
|
|
|
# Replaying the search process isn't a good design.
|
2011-02-01 22:18:07 +08:00
|
|
|
if self.exc_type and issubclass(self.exc_type, TemplateDoesNotExist):
|
2015-01-11 17:06:42 +08:00
|
|
|
if default_template_engine is None:
|
2014-11-16 03:58:26 +08:00
|
|
|
template_loaders = []
|
2015-01-11 17:06:42 +08:00
|
|
|
else:
|
|
|
|
self.template_does_not_exist = True
|
|
|
|
self.loader_debug_info = []
|
|
|
|
# If Django fails in get_template_loaders, provide an empty list
|
|
|
|
# for the following loop to not fail.
|
|
|
|
try:
|
|
|
|
template_loaders = default_template_engine.template_loaders
|
|
|
|
except Exception:
|
|
|
|
template_loaders = []
|
|
|
|
|
2014-11-16 03:58:26 +08:00
|
|
|
for loader in template_loaders:
|
2008-07-16 02:47:49 +08:00
|
|
|
try:
|
2011-04-03 02:48:18 +08:00
|
|
|
source_list_func = loader.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.
|
2013-02-24 23:41:10 +08:00
|
|
|
template_list = [{
|
|
|
|
'name': t,
|
|
|
|
'status': self.format_path_status(t),
|
|
|
|
} for t in source_list_func(str(self.exc_value))]
|
2011-04-03 02:48:18 +08:00
|
|
|
except AttributeError:
|
2008-07-16 02:47:49 +08:00
|
|
|
template_list = []
|
2011-04-03 02:48:18 +08:00
|
|
|
loader_name = loader.__module__ + '.' + loader.__class__.__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,
|
|
|
|
})
|
2015-01-11 17:06:42 +08:00
|
|
|
|
|
|
|
# TODO: add support for multiple template engines (#24119).
|
|
|
|
if (default_template_engine is not None
|
|
|
|
and default_template_engine.debug
|
|
|
|
and hasattr(self.exc_value, 'django_template_source')):
|
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()
|
2011-01-13 21:47:03 +08:00
|
|
|
for i, frame in enumerate(frames):
|
2011-02-01 22:18:07 +08:00
|
|
|
if 'vars' in frame:
|
2014-08-13 21:32:14 +08:00
|
|
|
frame_vars = []
|
|
|
|
for k, v in frame['vars']:
|
|
|
|
v = pprint(v)
|
|
|
|
# The force_escape filter assume unicode, make sure that works
|
|
|
|
if isinstance(v, six.binary_type):
|
|
|
|
v = v.decode('utf-8', 'replace') # don't choke on non-utf-8 input
|
|
|
|
# Trim large blobs of data
|
|
|
|
if len(v) > 4096:
|
|
|
|
v = '%s... <trimmed %d bytes string>' % (v[0:4096], len(v))
|
|
|
|
frame_vars.append((k, force_escape(v)))
|
|
|
|
frame['vars'] = frame_vars
|
2011-01-13 21:47:03 +08:00
|
|
|
frames[i] = frame
|
2008-02-03 10:24:56 +08:00
|
|
|
|
2008-07-16 02:47:49 +08:00
|
|
|
unicode_hint = ''
|
2011-02-01 22:18:07 +08:00
|
|
|
if self.exc_type and issubclass(self.exc_type, UnicodeError):
|
2008-07-16 02:47:49 +08:00
|
|
|
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]
|
2014-09-04 20:15:09 +08:00
|
|
|
unicode_hint = smart_text(
|
|
|
|
unicode_str[max(start - 5, 0):min(end + 5, len(unicode_str))],
|
|
|
|
'ascii', errors='replace'
|
|
|
|
)
|
2008-07-16 02:47:49 +08:00
|
|
|
from django import get_version
|
2011-10-02 10:53:58 +08:00
|
|
|
c = {
|
2010-12-06 22:21:51 +08:00
|
|
|
'is_email': self.is_email,
|
2008-07-16 02:47:49 +08:00
|
|
|
'unicode_hint': unicode_hint,
|
|
|
|
'frames': frames,
|
|
|
|
'request': self.request,
|
2011-06-09 06:18:46 +08:00
|
|
|
'filtered_POST': self.filter.get_post_parameters(self.request),
|
2008-07-16 02:47:49 +08:00
|
|
|
'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(),
|
2013-10-27 09:27:42 +08:00
|
|
|
'sys_path': sys.path,
|
2008-07-16 02:47:49 +08:00
|
|
|
'template_info': self.template_info,
|
|
|
|
'template_does_not_exist': self.template_does_not_exist,
|
|
|
|
'loader_debug_info': self.loader_debug_info,
|
2011-10-02 10:53:58 +08:00
|
|
|
}
|
2011-02-01 22:18:07 +08:00
|
|
|
# Check whether exception info is available
|
|
|
|
if self.exc_type:
|
|
|
|
c['exception_type'] = self.exc_type.__name__
|
|
|
|
if self.exc_value:
|
2012-07-21 16:00:10 +08:00
|
|
|
c['exception_value'] = smart_text(self.exc_value, errors='replace')
|
2011-02-01 22:18:07 +08:00
|
|
|
if frames:
|
|
|
|
c['lastframe'] = frames[-1]
|
2011-10-02 10:53:58 +08:00
|
|
|
return c
|
|
|
|
|
|
|
|
def get_traceback_html(self):
|
|
|
|
"Return HTML version of debug 500 HTTP error page."
|
2015-01-11 17:06:42 +08:00
|
|
|
t = DEBUG_ENGINE.from_string(TECHNICAL_500_TEMPLATE)
|
2012-10-20 20:50:44 +08:00
|
|
|
c = Context(self.get_traceback_data(), use_l10n=False)
|
2011-10-02 10:53:58 +08:00
|
|
|
return t.render(c)
|
|
|
|
|
|
|
|
def get_traceback_text(self):
|
|
|
|
"Return plain text version of debug 500 HTTP error page."
|
2015-01-11 17:06:42 +08:00
|
|
|
t = DEBUG_ENGINE.from_string(TECHNICAL_500_TEXT_TEMPLATE)
|
2012-10-20 20:50:44 +08:00
|
|
|
c = Context(self.get_traceback_data(), autoescape=False, use_l10n=False)
|
2008-07-16 02:47:49 +08:00
|
|
|
return t.render(c)
|
|
|
|
|
|
|
|
def get_template_exception_info(self):
|
2011-09-16 09:16:25 +08:00
|
|
|
origin, (start, end) = self.exc_value.django_template_source
|
2008-07-16 02:47:49 +08:00
|
|
|
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])
|
2013-10-15 03:13:14 +08:00
|
|
|
source_lines.append((num, escape(template_source[upto:next])))
|
2008-07-16 02:47:49 +08:00
|
|
|
upto = next
|
|
|
|
total = len(source_lines)
|
|
|
|
|
|
|
|
top = max(1, line - context_lines)
|
|
|
|
bottom = min(total, line + 1 + context_lines)
|
|
|
|
|
2011-12-23 06:08:32 +08:00
|
|
|
# In some rare cases, exc_value.args might be empty.
|
|
|
|
try:
|
|
|
|
message = self.exc_value.args[0]
|
|
|
|
except IndexError:
|
|
|
|
message = '(Could not get exception message)'
|
|
|
|
|
2008-07-16 02:47:49 +08:00
|
|
|
self.template_info = {
|
2011-12-23 06:08:32 +08:00
|
|
|
'message': message,
|
2008-07-16 02:47:49 +08:00
|
|
|
'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"):
|
2013-11-21 01:50:36 +08:00
|
|
|
try:
|
|
|
|
source = loader.get_source(module_name)
|
|
|
|
except ImportError:
|
|
|
|
pass
|
2008-07-16 02:47:49 +08:00
|
|
|
if source is not None:
|
|
|
|
source = source.splitlines()
|
|
|
|
if source is None:
|
2005-11-25 05:15:51 +08:00
|
|
|
try:
|
2012-05-19 23:43:34 +08:00
|
|
|
with open(filename, 'rb') as fp:
|
2013-05-19 00:26:34 +08:00
|
|
|
source = fp.read().splitlines()
|
2008-07-16 02:47:49 +08:00
|
|
|
except (OSError, IOError):
|
|
|
|
pass
|
|
|
|
if source is None:
|
|
|
|
return None, [], None, []
|
|
|
|
|
2012-09-27 03:41:47 +08:00
|
|
|
# If we just read the source from a file, or if the loader did not
|
|
|
|
# apply tokenize.detect_encoding to decode the source into a Unicode
|
|
|
|
# string, then we should do that ourselves.
|
|
|
|
if isinstance(source[0], six.binary_type):
|
|
|
|
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(br'coding[:=]\s*([-\w.]+)', line)
|
|
|
|
if match:
|
|
|
|
encoding = match.group(1).decode('ascii')
|
|
|
|
break
|
|
|
|
source = [six.text_type(sline, encoding, 'replace') for sline in source]
|
2008-07-16 02:47:49 +08:00
|
|
|
|
|
|
|
lower_bound = max(0, lineno - context_lines)
|
|
|
|
upper_bound = lineno + context_lines
|
|
|
|
|
2013-05-19 00:26:34 +08:00
|
|
|
pre_context = source[lower_bound:lineno]
|
|
|
|
context_line = source[lineno]
|
2013-11-04 02:08:55 +08:00
|
|
|
post_context = source[lineno + 1:upper_bound]
|
2008-07-16 02:47:49 +08:00
|
|
|
|
|
|
|
return lower_bound, pre_context, context_line, post_context
|
|
|
|
|
|
|
|
def get_traceback_frames(self):
|
|
|
|
frames = []
|
|
|
|
tb = self.tb
|
|
|
|
while tb is not None:
|
2011-06-09 06:18:46 +08:00
|
|
|
# Support for __traceback_hide__ which is used by a few libraries
|
2008-07-16 02:47:49 +08:00
|
|
|
# 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__')
|
2011-06-09 20:45:11 +08:00
|
|
|
module_name = tb.tb_frame.f_globals.get('__name__') or ''
|
2014-09-04 20:15:09 +08:00
|
|
|
pre_context_lineno, pre_context, context_line, post_context = self._get_lines_from_file(
|
|
|
|
filename, lineno, 7, loader, module_name,
|
|
|
|
)
|
2008-07-16 02:47:49 +08:00
|
|
|
if pre_context_lineno is not None:
|
|
|
|
frames.append({
|
|
|
|
'tb': tb,
|
2013-05-27 10:47:50 +08:00
|
|
|
'type': 'django' if module_name.startswith('django.') else 'user',
|
2008-07-16 02:47:49 +08:00
|
|
|
'filename': filename,
|
|
|
|
'function': function,
|
|
|
|
'lineno': lineno + 1,
|
2011-06-09 06:18:46 +08:00
|
|
|
'vars': self.filter.get_traceback_frame_variables(self.request, tb.tb_frame),
|
2008-07-16 02:47:49 +08:00
|
|
|
'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
|
|
|
return frames
|
|
|
|
|
|
|
|
def format_exception(self):
|
|
|
|
"""
|
|
|
|
Return the same data as from traceback.format_exception.
|
|
|
|
"""
|
|
|
|
import traceback
|
|
|
|
frames = self.get_traceback_frames()
|
2013-10-15 03:13:14 +08:00
|
|
|
tb = [(f['filename'], f['lineno'], f['function'], f['context_line']) for f in frames]
|
2008-07-16 02:47:49 +08:00
|
|
|
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:
|
2014-02-16 00:45:16 +08:00
|
|
|
error_url = exception.args[0]['path']
|
|
|
|
except (IndexError, TypeError, KeyError):
|
2014-02-16 02:42:12 +08:00
|
|
|
error_url = request.path_info[1:] # Trim leading slash
|
2014-02-16 00:45:16 +08:00
|
|
|
|
|
|
|
try:
|
|
|
|
tried = exception.args[0]['tried']
|
|
|
|
except (IndexError, TypeError, KeyError):
|
2005-11-15 01:44:50 +08:00
|
|
|
tried = []
|
2005-12-06 13:04:56 +08:00
|
|
|
else:
|
Simplified default project template.
Squashed commit of:
commit 508ec9144b35c50794708225b496bde1eb5e60aa
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 22:50:55 2013 +0100
Tweaked default settings file.
* Explained why BASE_DIR exists.
* Added a link to the database configuration options, and put it in its
own section.
* Moved sensitive settings that must be changed for production at the
top.
commit 6515fd2f1aa73a86dc8dbd2ccf512ddb6b140d57
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 14:35:21 2013 +0100
Documented the simplified app & project templates in the changelog.
commit 2c5b576c2ea91d84273a019b3d0b3b8b4da72f23
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 13:59:27 2013 +0100
Minor fixes in tutorials 5 and 6.
commit 55a51531be8104f21b3cca3f6bf70b0a7139a041
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 13:51:11 2013 +0100
Updated tutorial 2 for the new project template.
commit 29ddae87bdaecff12dd31b16b000c01efbde9e20
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 11:58:54 2013 +0100
Updated tutorial 1 for the new project template.
commit 0ecb9f6e2514cfd26a678a280d471433375101a3
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 11:29:13 2013 +0100
Adjusted the default URLconf detection to account for the admin.
It's now enabled by default.
commit 5fb4da0d3d09dac28dd94e3fde92b9d4335c0565
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 10:36:55 2013 +0100
Added security warnings for the most sensitive settings.
commit 718d84bd8ac4a42fb4b28ec93965de32680f091e
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:24:06 2013 +0100
Used an absolute path for the SQLite database.
This ensures the settings file works regardless of which directory
django-admin.py / manage.py is invoked from.
BASE_DIR got a +1 from a BDFL and another core dev. It doesn't involve
the concept of a "Django project"; it's just a convenient way to express
relative paths within the source code repository for non-Python files.
Thanks Jacob Kaplan-Moss for the suggestion.
commit 1b559b4bcda622e10909b68fe5cab90db6727dd9
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:22:40 2013 +0100
Removed STATIC_ROOT from the default settings template.
It isn't necessary in development, and it confuses beginners to no end.
Thanks Carl Meyer for the suggestion.
commit a55f141a500bb7c9a1bc259bbe1954c13b199671
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:21:43 2013 +0100
Removed MEDIA_ROOT/URL from default settings template.
Many sites will never deal with user-uploaded files, and MEDIA_ROOT is
complicated to explain.
Thanks Carl Meyer for the suggestion.
commit 44bf2f2441420fd9429ee9fe1f7207f92dd87e70
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:22:09 2013 +0100
Removed logging config.
This configuration is applied regardless of the value of LOGGING;
duplicating it in LOGGING is confusing.
commit eac747e848eaed65fd5f6f254f0a7559d856f88f
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:05:31 2013 +0100
Enabled the locale middleware by default.
USE_I18N is True by default, and doesn't work well without
LocaleMiddleware.
commit d806c62b2d00826dc2688c84b092627b8d571cab
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:03:16 2013 +0100
Enabled clickjacking protection by default.
commit 99152c30e6a15003f0b6737dc78e87adf462aacb
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:01:48 2013 +0100
Reorganized settings in logical sections, and trimmed comments.
commit d37ffdfcb24b7e0ec7cc113d07190f65fb12fb8a
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:54:11 2013 +0100
Avoided misleading TEMPLATE_DEBUG = DEBUG.
According to the docs TEMPLATE_DEBUG works only when DEBUG = True.
commit 15d9478d3a9850e85841e7cf09cf83050371c6bf
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:46:25 2013 +0100
Removed STATICFILES_FINDERS/TEMPLATE_LOADERS from default settings file.
Only developers with special needs ever need to change these settings.
commit 574da0eb5bfb4570883756914b4dbd7e20e1f61e
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:45:01 2013 +0100
Removed STATICFILES/TEMPLATES_DIRS from default settings file.
The current best practice is to put static files and templates in
applications, for easier testing and deployment.
commit 8cb18dbe56629aa1be74718a07e7cc66b4f9c9f0
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:24:16 2013 +0100
Removed settings related to email reporting from default settings file.
While handy for small scale projects, it isn't exactly a best practice.
commit 8ecbfcb3638058f0c49922540f874a7d802d864f
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 18:54:43 2013 +0100
Documented how to enable the sites framework.
commit 23fc91a6fa67d91ddd9d71b1c3e0dc26bdad9841
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:28:59 2013 +0100
Disabled the sites framework by default.
RequestSite does the job for single-domain websites.
commit c4d82eb8afc0eb8568bf9c4d12644272415e3960
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 00:08:33 2013 +0100
Added a default admin.py to the application template.
Thanks Ryan D Hiebert for the suggestion.
commit 4071dc771e5c44b1c5ebb9beecefb164ae465e22
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 10:59:49 2013 +0100
Enabled the admin by default.
Everyone uses the admin.
commit c807a31f8d89e7e7fd97380e3023f7983a8b6fcb
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 10:57:05 2013 +0100
Removed admindocs from default project template.
commit 09e4ce0e652a97da1a9e285046a91c8ad7a9189c
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:32:52 2013 +0100
Added links to the settings documentation.
commit 5b8f5eaef364eb790fcde6f9e86f7d266074cca8
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 11:06:54 2013 +0100
Used a significant example for URLconf includes.
commit 908e91d6fcee2a3cb51ca26ecdf12a6a24e69ef8
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:22:31 2013 +0100
Moved code comments about WSGI to docs, and rewrote said docs.
commit 50417e51996146f891d08ca8b74dcc736a581932
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 15:51:50 2013 +0100
Normalized the default application template.
Removed the default test that 1 + 1 = 2, because it's been committed
way too many times, in too many projects.
Added an import of `render` for views, because the first view will
often be:
def home(request):
return render(request, "mysite/home.html")
2013-01-28 22:51:50 +08:00
|
|
|
if (not tried # empty URLconf
|
|
|
|
or (request.path == '/'
|
|
|
|
and len(tried) == 1 # default URLconf
|
|
|
|
and len(tried[0]) == 1
|
2013-12-07 10:21:58 +08:00
|
|
|
and getattr(tried[0][0], 'app_name', '') == getattr(tried[0][0], 'namespace', '') == 'admin')):
|
Simplified default project template.
Squashed commit of:
commit 508ec9144b35c50794708225b496bde1eb5e60aa
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 22:50:55 2013 +0100
Tweaked default settings file.
* Explained why BASE_DIR exists.
* Added a link to the database configuration options, and put it in its
own section.
* Moved sensitive settings that must be changed for production at the
top.
commit 6515fd2f1aa73a86dc8dbd2ccf512ddb6b140d57
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 14:35:21 2013 +0100
Documented the simplified app & project templates in the changelog.
commit 2c5b576c2ea91d84273a019b3d0b3b8b4da72f23
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 13:59:27 2013 +0100
Minor fixes in tutorials 5 and 6.
commit 55a51531be8104f21b3cca3f6bf70b0a7139a041
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 13:51:11 2013 +0100
Updated tutorial 2 for the new project template.
commit 29ddae87bdaecff12dd31b16b000c01efbde9e20
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 11:58:54 2013 +0100
Updated tutorial 1 for the new project template.
commit 0ecb9f6e2514cfd26a678a280d471433375101a3
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 11:29:13 2013 +0100
Adjusted the default URLconf detection to account for the admin.
It's now enabled by default.
commit 5fb4da0d3d09dac28dd94e3fde92b9d4335c0565
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 10:36:55 2013 +0100
Added security warnings for the most sensitive settings.
commit 718d84bd8ac4a42fb4b28ec93965de32680f091e
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:24:06 2013 +0100
Used an absolute path for the SQLite database.
This ensures the settings file works regardless of which directory
django-admin.py / manage.py is invoked from.
BASE_DIR got a +1 from a BDFL and another core dev. It doesn't involve
the concept of a "Django project"; it's just a convenient way to express
relative paths within the source code repository for non-Python files.
Thanks Jacob Kaplan-Moss for the suggestion.
commit 1b559b4bcda622e10909b68fe5cab90db6727dd9
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:22:40 2013 +0100
Removed STATIC_ROOT from the default settings template.
It isn't necessary in development, and it confuses beginners to no end.
Thanks Carl Meyer for the suggestion.
commit a55f141a500bb7c9a1bc259bbe1954c13b199671
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:21:43 2013 +0100
Removed MEDIA_ROOT/URL from default settings template.
Many sites will never deal with user-uploaded files, and MEDIA_ROOT is
complicated to explain.
Thanks Carl Meyer for the suggestion.
commit 44bf2f2441420fd9429ee9fe1f7207f92dd87e70
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:22:09 2013 +0100
Removed logging config.
This configuration is applied regardless of the value of LOGGING;
duplicating it in LOGGING is confusing.
commit eac747e848eaed65fd5f6f254f0a7559d856f88f
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:05:31 2013 +0100
Enabled the locale middleware by default.
USE_I18N is True by default, and doesn't work well without
LocaleMiddleware.
commit d806c62b2d00826dc2688c84b092627b8d571cab
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:03:16 2013 +0100
Enabled clickjacking protection by default.
commit 99152c30e6a15003f0b6737dc78e87adf462aacb
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:01:48 2013 +0100
Reorganized settings in logical sections, and trimmed comments.
commit d37ffdfcb24b7e0ec7cc113d07190f65fb12fb8a
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:54:11 2013 +0100
Avoided misleading TEMPLATE_DEBUG = DEBUG.
According to the docs TEMPLATE_DEBUG works only when DEBUG = True.
commit 15d9478d3a9850e85841e7cf09cf83050371c6bf
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:46:25 2013 +0100
Removed STATICFILES_FINDERS/TEMPLATE_LOADERS from default settings file.
Only developers with special needs ever need to change these settings.
commit 574da0eb5bfb4570883756914b4dbd7e20e1f61e
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:45:01 2013 +0100
Removed STATICFILES/TEMPLATES_DIRS from default settings file.
The current best practice is to put static files and templates in
applications, for easier testing and deployment.
commit 8cb18dbe56629aa1be74718a07e7cc66b4f9c9f0
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:24:16 2013 +0100
Removed settings related to email reporting from default settings file.
While handy for small scale projects, it isn't exactly a best practice.
commit 8ecbfcb3638058f0c49922540f874a7d802d864f
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 18:54:43 2013 +0100
Documented how to enable the sites framework.
commit 23fc91a6fa67d91ddd9d71b1c3e0dc26bdad9841
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:28:59 2013 +0100
Disabled the sites framework by default.
RequestSite does the job for single-domain websites.
commit c4d82eb8afc0eb8568bf9c4d12644272415e3960
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 00:08:33 2013 +0100
Added a default admin.py to the application template.
Thanks Ryan D Hiebert for the suggestion.
commit 4071dc771e5c44b1c5ebb9beecefb164ae465e22
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 10:59:49 2013 +0100
Enabled the admin by default.
Everyone uses the admin.
commit c807a31f8d89e7e7fd97380e3023f7983a8b6fcb
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 10:57:05 2013 +0100
Removed admindocs from default project template.
commit 09e4ce0e652a97da1a9e285046a91c8ad7a9189c
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:32:52 2013 +0100
Added links to the settings documentation.
commit 5b8f5eaef364eb790fcde6f9e86f7d266074cca8
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 11:06:54 2013 +0100
Used a significant example for URLconf includes.
commit 908e91d6fcee2a3cb51ca26ecdf12a6a24e69ef8
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:22:31 2013 +0100
Moved code comments about WSGI to docs, and rewrote said docs.
commit 50417e51996146f891d08ca8b74dcc736a581932
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 15:51:50 2013 +0100
Normalized the default application template.
Removed the default test that 1 + 1 = 2, because it's been committed
way too many times, in too many projects.
Added an import of `render` for views, because the first view will
often be:
def home(request):
return render(request, "mysite/home.html")
2013-01-28 22:51:50 +08:00
|
|
|
return default_urlconf(request)
|
2005-11-17 11:10:03 +08:00
|
|
|
|
2010-12-13 06:54:04 +08:00
|
|
|
urlconf = getattr(request, 'urlconf', settings.ROOT_URLCONF)
|
|
|
|
if isinstance(urlconf, types.ModuleType):
|
|
|
|
urlconf = urlconf.__name__
|
|
|
|
|
2014-06-16 15:39:18 +08:00
|
|
|
caller = ''
|
|
|
|
try:
|
|
|
|
resolver_match = resolve(request.path)
|
|
|
|
except Resolver404:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
obj = resolver_match.func
|
|
|
|
|
|
|
|
if hasattr(obj, '__name__'):
|
|
|
|
caller = obj.__name__
|
|
|
|
elif hasattr(obj, '__class__') and hasattr(obj.__class__, '__name__'):
|
|
|
|
caller = obj.__class__.__name__
|
|
|
|
|
|
|
|
if hasattr(obj, '__module__'):
|
|
|
|
module = obj.__module__
|
|
|
|
caller = '%s.%s' % (module, caller)
|
|
|
|
|
2015-01-11 17:06:42 +08:00
|
|
|
t = DEBUG_ENGINE.from_string(TECHNICAL_404_TEMPLATE)
|
2005-11-15 01:44:50 +08:00
|
|
|
c = Context({
|
2010-12-13 06:54:04 +08:00
|
|
|
'urlconf': urlconf,
|
2005-11-24 07:10:17 +08:00
|
|
|
'root_urlconf': settings.ROOT_URLCONF,
|
2014-02-15 21:41:01 +08:00
|
|
|
'request_path': error_url,
|
2005-11-24 07:10:17 +08:00
|
|
|
'urlpatterns': tried,
|
2012-08-29 02:59:56 +08:00
|
|
|
'reason': force_bytes(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(),
|
2014-06-16 15:39:18 +08:00
|
|
|
'raising_view_name': caller,
|
2005-12-07 14:02:09 +08:00
|
|
|
})
|
2012-07-01 03:19:07 +08:00
|
|
|
return HttpResponseNotFound(t.render(c), content_type='text/html')
|
2005-12-07 14:02:09 +08:00
|
|
|
|
2013-11-03 07:53:29 +08:00
|
|
|
|
Simplified default project template.
Squashed commit of:
commit 508ec9144b35c50794708225b496bde1eb5e60aa
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 22:50:55 2013 +0100
Tweaked default settings file.
* Explained why BASE_DIR exists.
* Added a link to the database configuration options, and put it in its
own section.
* Moved sensitive settings that must be changed for production at the
top.
commit 6515fd2f1aa73a86dc8dbd2ccf512ddb6b140d57
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 14:35:21 2013 +0100
Documented the simplified app & project templates in the changelog.
commit 2c5b576c2ea91d84273a019b3d0b3b8b4da72f23
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 13:59:27 2013 +0100
Minor fixes in tutorials 5 and 6.
commit 55a51531be8104f21b3cca3f6bf70b0a7139a041
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 13:51:11 2013 +0100
Updated tutorial 2 for the new project template.
commit 29ddae87bdaecff12dd31b16b000c01efbde9e20
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 11:58:54 2013 +0100
Updated tutorial 1 for the new project template.
commit 0ecb9f6e2514cfd26a678a280d471433375101a3
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 11:29:13 2013 +0100
Adjusted the default URLconf detection to account for the admin.
It's now enabled by default.
commit 5fb4da0d3d09dac28dd94e3fde92b9d4335c0565
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 10:36:55 2013 +0100
Added security warnings for the most sensitive settings.
commit 718d84bd8ac4a42fb4b28ec93965de32680f091e
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:24:06 2013 +0100
Used an absolute path for the SQLite database.
This ensures the settings file works regardless of which directory
django-admin.py / manage.py is invoked from.
BASE_DIR got a +1 from a BDFL and another core dev. It doesn't involve
the concept of a "Django project"; it's just a convenient way to express
relative paths within the source code repository for non-Python files.
Thanks Jacob Kaplan-Moss for the suggestion.
commit 1b559b4bcda622e10909b68fe5cab90db6727dd9
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:22:40 2013 +0100
Removed STATIC_ROOT from the default settings template.
It isn't necessary in development, and it confuses beginners to no end.
Thanks Carl Meyer for the suggestion.
commit a55f141a500bb7c9a1bc259bbe1954c13b199671
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:21:43 2013 +0100
Removed MEDIA_ROOT/URL from default settings template.
Many sites will never deal with user-uploaded files, and MEDIA_ROOT is
complicated to explain.
Thanks Carl Meyer for the suggestion.
commit 44bf2f2441420fd9429ee9fe1f7207f92dd87e70
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:22:09 2013 +0100
Removed logging config.
This configuration is applied regardless of the value of LOGGING;
duplicating it in LOGGING is confusing.
commit eac747e848eaed65fd5f6f254f0a7559d856f88f
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:05:31 2013 +0100
Enabled the locale middleware by default.
USE_I18N is True by default, and doesn't work well without
LocaleMiddleware.
commit d806c62b2d00826dc2688c84b092627b8d571cab
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:03:16 2013 +0100
Enabled clickjacking protection by default.
commit 99152c30e6a15003f0b6737dc78e87adf462aacb
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:01:48 2013 +0100
Reorganized settings in logical sections, and trimmed comments.
commit d37ffdfcb24b7e0ec7cc113d07190f65fb12fb8a
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:54:11 2013 +0100
Avoided misleading TEMPLATE_DEBUG = DEBUG.
According to the docs TEMPLATE_DEBUG works only when DEBUG = True.
commit 15d9478d3a9850e85841e7cf09cf83050371c6bf
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:46:25 2013 +0100
Removed STATICFILES_FINDERS/TEMPLATE_LOADERS from default settings file.
Only developers with special needs ever need to change these settings.
commit 574da0eb5bfb4570883756914b4dbd7e20e1f61e
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:45:01 2013 +0100
Removed STATICFILES/TEMPLATES_DIRS from default settings file.
The current best practice is to put static files and templates in
applications, for easier testing and deployment.
commit 8cb18dbe56629aa1be74718a07e7cc66b4f9c9f0
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:24:16 2013 +0100
Removed settings related to email reporting from default settings file.
While handy for small scale projects, it isn't exactly a best practice.
commit 8ecbfcb3638058f0c49922540f874a7d802d864f
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 18:54:43 2013 +0100
Documented how to enable the sites framework.
commit 23fc91a6fa67d91ddd9d71b1c3e0dc26bdad9841
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:28:59 2013 +0100
Disabled the sites framework by default.
RequestSite does the job for single-domain websites.
commit c4d82eb8afc0eb8568bf9c4d12644272415e3960
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 00:08:33 2013 +0100
Added a default admin.py to the application template.
Thanks Ryan D Hiebert for the suggestion.
commit 4071dc771e5c44b1c5ebb9beecefb164ae465e22
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 10:59:49 2013 +0100
Enabled the admin by default.
Everyone uses the admin.
commit c807a31f8d89e7e7fd97380e3023f7983a8b6fcb
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 10:57:05 2013 +0100
Removed admindocs from default project template.
commit 09e4ce0e652a97da1a9e285046a91c8ad7a9189c
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:32:52 2013 +0100
Added links to the settings documentation.
commit 5b8f5eaef364eb790fcde6f9e86f7d266074cca8
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 11:06:54 2013 +0100
Used a significant example for URLconf includes.
commit 908e91d6fcee2a3cb51ca26ecdf12a6a24e69ef8
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:22:31 2013 +0100
Moved code comments about WSGI to docs, and rewrote said docs.
commit 50417e51996146f891d08ca8b74dcc736a581932
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 15:51:50 2013 +0100
Normalized the default application template.
Removed the default test that 1 + 1 = 2, because it's been committed
way too many times, in too many projects.
Added an import of `render` for views, because the first view will
often be:
def home(request):
return render(request, "mysite/home.html")
2013-01-28 22:51:50 +08:00
|
|
|
def default_urlconf(request):
|
2005-12-07 14:02:09 +08:00
|
|
|
"Create an empty URLconf 404 error response."
|
2015-01-11 17:06:42 +08:00
|
|
|
t = DEBUG_ENGINE.from_string(DEFAULT_URLCONF_TEMPLATE)
|
2014-05-18 06:26:46 +08:00
|
|
|
c = Context({
|
|
|
|
"title": _("Welcome to Django"),
|
|
|
|
"heading": _("It worked!"),
|
|
|
|
"subheading": _("Congratulations on your first Django-powered page."),
|
|
|
|
"instructions": _("Of course, you haven't actually done any work yet. "
|
|
|
|
"Next, start your first app by running <code>python manage.py startapp [app_label]</code>."),
|
|
|
|
"explanation": _("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!"),
|
|
|
|
})
|
|
|
|
|
2012-07-01 03:19:07 +08:00
|
|
|
return HttpResponse(t.render(c), content_type='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.
|
|
|
|
#
|
|
|
|
|
2014-09-04 20:15:09 +08:00
|
|
|
TECHNICAL_500_TEMPLATE = ("""
|
2011-04-21 01:44:29 +08:00
|
|
|
<!DOCTYPE html>
|
2005-11-15 01:44:50 +08:00
|
|
|
<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">
|
2014-09-04 20:15:09 +08:00
|
|
|
<title>{% if exception_type %}{{ exception_type }}{% else %}Report{% endif %}"""
|
|
|
|
"""{% if request %} at {{ request.path_info|escape }}{% endif %}</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; }
|
2011-08-22 08:12:51 +08:00
|
|
|
code, pre { font-size: 100%; white-space: pre-wrap; }
|
2005-11-15 01:44:50 +08:00
|
|
|
table { border:1px solid #ccc; border-collapse: collapse; width:100%; background:white; }
|
|
|
|
tbody td, tbody th { vertical-align:top; padding:2px 3px; }
|
2014-09-04 20:15:09 +08:00
|
|
|
thead th {
|
|
|
|
padding:1px 6px 1px 3px; background:#fefefe; text-align:left;
|
|
|
|
font-weight:normal; font-size:11px; border:1px solid #ddd;
|
|
|
|
}
|
2005-11-15 01:44:50 +08:00
|
|
|
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%; }
|
2010-12-06 22:21:51 +08:00
|
|
|
table td.code pre { 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; }
|
2011-06-09 20:45:11 +08:00
|
|
|
ul.traceback { list-style-type:none; color: #222; }
|
|
|
|
ul.traceback li.frame { padding-bottom:1em; color:#666; }
|
|
|
|
ul.traceback li.user { background-color:#e0e0e0; color:#000 }
|
2011-01-24 19:49:11 +08:00
|
|
|
div.context { padding:10px 0; overflow:hidden; }
|
2005-11-15 01:44:50 +08:00
|
|
|
div.context ol { padding-left:30px; margin:0 10px; list-style-position: inside; }
|
2011-06-09 20:45:11 +08:00
|
|
|
div.context ol li { font-family:monospace; white-space:pre; color:#777; cursor:pointer; }
|
2011-01-24 19:49:11 +08:00
|
|
|
div.context ol li pre { display:inline; }
|
2011-06-09 20:45:11 +08:00
|
|
|
div.context ol.context-line li { color:#505050; background-color:#dfdfdf; }
|
2011-01-24 19:49:11 +08:00
|
|
|
div.context ol.context-line li span { position:absolute; right:32px; }
|
2011-06-09 20:45:11 +08:00
|
|
|
.user div.context ol.context-line li { background-color:#bbb; color:#000; }
|
|
|
|
.user div.context ol li { color:#666; }
|
2005-11-15 01:44:50 +08:00
|
|
|
div.commands { margin-left: 40px; }
|
2011-06-09 20:45:11 +08:00
|
|
|
div.commands a { color:#555; text-decoration:none; }
|
|
|
|
.user div.commands a { color: black; }
|
2005-11-15 01:44:50 +08:00
|
|
|
#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>
|
2010-12-06 22:21:51 +08:00
|
|
|
{% if not is_email %}
|
2005-11-15 01:44:50 +08:00
|
|
|
<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) {
|
2013-10-27 09:27:42 +08:00
|
|
|
e.style.display = e.style.display == 'none' ? 'block': 'none';
|
2005-11-15 01:44:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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";
|
2013-10-27 09:27:42 +08:00
|
|
|
link.innerHTML = link.innerHTML == s1 ? s2: s1;
|
2006-02-28 23:52:57 +08:00
|
|
|
toggle('browserTraceback', 'pastebinTraceback');
|
|
|
|
return false;
|
|
|
|
}
|
2005-11-17 22:19:33 +08:00
|
|
|
//-->
|
2005-11-15 01:44:50 +08:00
|
|
|
</script>
|
2010-12-06 22:21:51 +08:00
|
|
|
{% endif %}
|
2005-11-15 01:44:50 +08:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="summary">
|
2014-09-04 20:15:09 +08:00
|
|
|
<h1>{% if exception_type %}{{ exception_type }}{% else %}Report{% endif %}"""
|
|
|
|
"""{% if request %} at {{ request.path_info|escape }}{% endif %}</h1>
|
|
|
|
<pre class="exception_value">"""
|
|
|
|
"""{% if exception_value %}{{ exception_value|force_escape }}{% else %}No exception message supplied{% endif %}"""
|
|
|
|
"""</pre>
|
2005-11-15 01:44:50 +08:00
|
|
|
<table class="meta">
|
2011-02-01 22:18:07 +08:00
|
|
|
{% if request %}
|
2005-11-15 01:44:50 +08:00
|
|
|
<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>
|
2011-02-01 22:18:07 +08:00
|
|
|
{% endif %}
|
2010-02-25 03:39:04 +08:00
|
|
|
<tr>
|
|
|
|
<th>Django Version:</th>
|
|
|
|
<td>{{ django_version_info }}</td>
|
|
|
|
</tr>
|
2011-02-01 22:18:07 +08:00
|
|
|
{% if exception_type %}
|
2005-11-15 01:44:50 +08:00
|
|
|
<tr>
|
|
|
|
<th>Exception Type:</th>
|
|
|
|
<td>{{ exception_type }}</td>
|
|
|
|
</tr>
|
2011-02-01 22:18:07 +08:00
|
|
|
{% endif %}
|
|
|
|
{% if exception_type and exception_value %}
|
2005-11-15 01:44:50 +08:00
|
|
|
<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>
|
2011-02-01 22:18:07 +08:00
|
|
|
{% endif %}
|
|
|
|
{% if lastframe %}
|
2005-11-15 01:44:50 +08:00
|
|
|
<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>
|
2011-02-01 22:18:07 +08:00
|
|
|
{% endif %}
|
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>
|
2010-12-06 22:21:51 +08:00
|
|
|
<td><pre>{{ sys_path|pprint }}</pre></td>
|
2007-12-11 13:22:11 +08:00
|
|
|
</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>:
|
2013-02-24 23:41:10 +08:00
|
|
|
<ul>
|
|
|
|
{% for t in loader.templates %}<li><code>{{ t.name }}</code> ({{ t.status }})</li>{% endfor %}
|
|
|
|
</ul>
|
2005-11-25 05:15:51 +08:00
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% else %}
|
2014-12-18 05:10:57 +08:00
|
|
|
<p>Django couldn't find any templates because your <code>'loaders'</code> option is empty!</p>
|
2005-11-25 05:15:51 +08:00
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2005-11-24 07:10:17 +08:00
|
|
|
{% if template_info %}
|
|
|
|
<div id="template">
|
2011-09-16 09:16:25 +08:00
|
|
|
<h2>Error during template rendering</h2>
|
2005-11-24 07:15:52 +08:00
|
|
|
<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>
|
2014-09-04 20:15:09 +08:00
|
|
|
<table class="source{% if template_info.top %} cut-top{% endif %}
|
|
|
|
{% ifnotequal template_info.bottom template_info.total %} cut-bottom{% endifnotequal %}">
|
2005-11-24 07:10:17 +08:00
|
|
|
{% for source_line in template_info.source_lines %}
|
|
|
|
{% ifequal source_line.0 template_info.line %}
|
2014-09-04 20:15:09 +08:00
|
|
|
<tr class="error"><th>{{ source_line.0 }}</th>
|
|
|
|
<td>
|
|
|
|
{{ template_info.before }}
|
|
|
|
<span class="specific">{{ template_info.during }}</span>
|
|
|
|
{{ template_info.after }}
|
|
|
|
</td>
|
|
|
|
</tr>
|
2005-11-24 07:10:17 +08:00
|
|
|
{% 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 %}
|
2011-02-01 22:18:07 +08:00
|
|
|
{% if frames %}
|
2005-11-15 01:44:50 +08:00
|
|
|
<div id="traceback">
|
2014-09-04 20:15:09 +08:00
|
|
|
<h2>Traceback <span class="commands">{% if not is_email %}<a href="#" onclick="return switchPastebinFriendly(this);">
|
|
|
|
Switch to copy-and-paste view</a></span>{% endif %}
|
|
|
|
</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 %}
|
2011-06-09 20:45:11 +08:00
|
|
|
<li class="frame {{ frame.type }}">
|
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 }}">
|
2010-12-06 22:21:51 +08:00
|
|
|
{% if frame.pre_context and not is_email %}
|
2014-09-04 20:15:09 +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 }}')"><pre>{{ line|escape }}</pre></li>
|
|
|
|
{% endfor %}
|
|
|
|
</ol>
|
2006-02-28 23:52:57 +08:00
|
|
|
{% endif %}
|
2014-09-04 20:15:09 +08:00
|
|
|
<ol start="{{ frame.lineno }}" class="context-line">
|
|
|
|
<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')"><pre>
|
|
|
|
{{ frame.context_line|escape }}</pre>{% if not is_email %} <span>...</span>{% endif %}</li></ol>
|
2010-12-06 22:21:51 +08:00
|
|
|
{% if frame.post_context and not is_email %}
|
2014-09-04 20:15:09 +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 }}')"><pre>{{ line|escape }}</pre></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">
|
2010-12-06 22:21:51 +08:00
|
|
|
{% if is_email %}
|
|
|
|
<h2>Local Vars</h2>
|
|
|
|
{% else %}
|
|
|
|
<a href="#" onclick="return varToggle(this, '{{ frame.id }}')"><span>▶</span> Local vars</a>
|
|
|
|
{% endif %}
|
2006-02-28 23:52:57 +08:00
|
|
|
</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>
|
2011-01-13 21:47:03 +08:00
|
|
|
<td class="code"><pre>{{ var.1 }}</pre></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">
|
2010-12-06 22:21:51 +08:00
|
|
|
{% if not is_email %}
|
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">
|
2014-09-04 20:15:09 +08:00
|
|
|
<input type="hidden" name="title"
|
|
|
|
value="{{ exception_type|escape }}{% if request %} at {{ request.path_info|escape }}{% endif %}">
|
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:
|
|
|
|
|
2010-12-06 22:21:51 +08:00
|
|
|
{% if request %}
|
2007-12-02 08:00:36 +08:00
|
|
|
Request Method: {{ request.META.REQUEST_METHOD }}
|
2009-04-12 10:23:19 +08:00
|
|
|
Request URL: {{ request.build_absolute_uri|escape }}
|
2010-12-06 22:21:51 +08:00
|
|
|
{% endif %}
|
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 }}:
|
2013-02-24 23:41:10 +08:00
|
|
|
{% for t in loader.templates %}{{ t.name }} ({{ t.status }})
|
2007-12-02 08:00:36 +08:00
|
|
|
{% endfor %}{% endfor %}
|
2014-12-18 05:10:57 +08:00
|
|
|
{% else %}Django couldn't find any templates because your 'loaders' option is empty!
|
2007-12-02 08:00:36 +08:00
|
|
|
{% endif %}
|
|
|
|
{% endif %}{% if template_info %}
|
|
|
|
Template error:
|
|
|
|
In template {{ template_info.name }}, error at line {{ template_info.line }}
|
2014-09-04 20:15:09 +08:00
|
|
|
{{ template_info.message }}{% for source_line in template_info.source_lines %}
|
|
|
|
{% ifequal source_line.0 template_info.line %}
|
2007-12-02 08:00:36 +08:00
|
|
|
{{ 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 %}
|
2010-12-06 22:21:51 +08:00
|
|
|
Exception Type: {{ exception_type|escape }}{% if request %} at {{ request.path_info|escape }}{% endif %}
|
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>
|
2010-12-06 22:21:51 +08:00
|
|
|
{% endif %}
|
2011-02-01 22:18:07 +08:00
|
|
|
{% endif %}
|
2005-11-15 01:44:50 +08:00
|
|
|
|
|
|
|
<div id="requestinfo">
|
|
|
|
<h2>Request information</h2>
|
2005-11-17 11:10:03 +08:00
|
|
|
|
2010-12-06 22:21:51 +08:00
|
|
|
{% if request %}
|
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>
|
2010-12-06 22:21:51 +08:00
|
|
|
<td class="code"><pre>{{ var.1|pprint }}</pre></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>
|
2011-06-09 06:18:46 +08:00
|
|
|
{% if filtered_POST %}
|
2005-11-15 01:44:50 +08:00
|
|
|
<table class="req">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Variable</th>
|
|
|
|
<th>Value</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
2005-11-17 22:19:33 +08:00
|
|
|
<tbody>
|
2011-06-09 06:18:46 +08:00
|
|
|
{% for var in filtered_POST.items %}
|
2005-11-15 01:44:50 +08:00
|
|
|
<tr>
|
|
|
|
<td>{{ var.0 }}</td>
|
2010-12-06 22:21:51 +08:00
|
|
|
<td class="code"><pre>{{ var.1|pprint }}</pre></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>
|
2010-12-06 22:21:51 +08:00
|
|
|
<td class="code"><pre>{{ var.1|pprint }}</pre></td>
|
2009-04-01 01:10:06 +08:00
|
|
|
</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>
|
2010-12-06 22:21:51 +08:00
|
|
|
<td class="code"><pre>{{ var.1|pprint }}</pre></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>
|
2010-12-06 22:21:51 +08:00
|
|
|
<td class="code"><pre>{{ var.1|pprint }}</pre></td>
|
2005-11-15 01:44:50 +08:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2011-02-01 22:18:07 +08:00
|
|
|
{% else %}
|
|
|
|
<p>Request data not supplied</p>
|
2010-12-06 22:21:51 +08:00
|
|
|
{% endif %}
|
2005-11-15 01:44:50 +08:00
|
|
|
|
|
|
|
<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>
|
2010-12-06 22:21:51 +08:00
|
|
|
<td class="code"><pre>{{ var.1|pprint }}</pre></td>
|
2005-11-15 01:44:50 +08:00
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
</div>
|
2011-03-14 22:58:54 +08:00
|
|
|
{% if not is_email %}
|
|
|
|
<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
|
2014-06-24 12:13:34 +08:00
|
|
|
display a standard page generated by the handler for this status code.
|
2011-03-14 22:58:54 +08:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
{% endif %}
|
2005-11-15 01:44:50 +08:00
|
|
|
</body>
|
|
|
|
</html>
|
2014-09-04 20:15:09 +08:00
|
|
|
""")
|
2005-11-15 01:44:50 +08:00
|
|
|
|
2014-03-28 04:24:19 +08:00
|
|
|
TECHNICAL_500_TEXT_TEMPLATE = """{% firstof exception_type 'Report' %}{% if request %} at {{ request.path_info }}{% endif %}
|
2013-04-24 02:17:04 +08:00
|
|
|
{% firstof exception_value 'No exception message supplied' %}
|
2011-10-02 10:53:58 +08:00
|
|
|
{% if request %}
|
|
|
|
Request Method: {{ request.META.REQUEST_METHOD }}
|
|
|
|
Request URL: {{ request.build_absolute_uri }}{% endif %}
|
|
|
|
Django Version: {{ django_version_info }}
|
|
|
|
Python Executable: {{ sys_executable }}
|
|
|
|
Python Version: {{ sys_version_info }}
|
|
|
|
Python Path: {{ sys_path }}
|
|
|
|
Server time: {{server_time|date:"r"}}
|
|
|
|
Installed Applications:
|
|
|
|
{{ settings.INSTALLED_APPS|pprint }}
|
|
|
|
Installed Middleware:
|
|
|
|
{{ settings.MIDDLEWARE_CLASSES|pprint }}
|
|
|
|
{% 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 }}:
|
2013-02-24 23:41:10 +08:00
|
|
|
{% for t in loader.templates %}{{ t.name }} ({{ t.status }})
|
2011-10-02 10:53:58 +08:00
|
|
|
{% endfor %}{% endfor %}
|
2014-12-18 05:10:57 +08:00
|
|
|
{% else %}Django couldn't find any templates because your 'loaders' option is empty!
|
2011-10-02 10:53:58 +08:00
|
|
|
{% endif %}
|
|
|
|
{% endif %}{% if template_info %}
|
|
|
|
Template error:
|
|
|
|
In template {{ template_info.name }}, error at line {{ template_info.line }}
|
2014-09-04 20:15:09 +08:00
|
|
|
{{ template_info.message }}{% for source_line in template_info.source_lines %}
|
|
|
|
{% ifequal source_line.0 template_info.line %}
|
2011-10-02 10:53:58 +08:00
|
|
|
{{ source_line.0 }} : {{ template_info.before }} {{ template_info.during }} {{ template_info.after }}
|
|
|
|
{% else %}
|
|
|
|
{{ source_line.0 }} : {{ source_line.1 }}
|
|
|
|
{% endifequal %}{% endfor %}{% endif %}{% if frames %}
|
|
|
|
Traceback:
|
|
|
|
{% for frame in frames %}File "{{ frame.filename }}" in {{ frame.function }}
|
|
|
|
{% if frame.context_line %} {{ frame.lineno }}. {{ frame.context_line }}{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% if exception_type %}Exception Type: {{ exception_type }}{% if request %} at {{ request.path_info }}{% endif %}
|
|
|
|
{% if exception_value %}Exception Value: {{ exception_value }}{% endif %}{% endif %}{% endif %}
|
|
|
|
{% if request %}Request information:
|
|
|
|
GET:{% for k, v in request.GET.items %}
|
|
|
|
{{ k }} = {{ v|stringformat:"r" }}{% empty %} No GET data{% endfor %}
|
|
|
|
|
|
|
|
POST:{% for k, v in filtered_POST.items %}
|
|
|
|
{{ k }} = {{ v|stringformat:"r" }}{% empty %} No POST data{% endfor %}
|
|
|
|
|
|
|
|
FILES:{% for k, v in request.FILES.items %}
|
|
|
|
{{ k }} = {{ v|stringformat:"r" }}{% empty %} No FILES data{% endfor %}
|
|
|
|
|
|
|
|
COOKIES:{% for k, v in request.COOKIES.items %}
|
|
|
|
{{ k }} = {{ v|stringformat:"r" }}{% empty %} No cookie data{% endfor %}
|
|
|
|
|
|
|
|
META:{% for k, v in request.META.items|dictsort:"0" %}
|
|
|
|
{{ k }} = {{ v|stringformat:"r" }}{% endfor %}
|
|
|
|
{% else %}Request data not supplied
|
|
|
|
{% endif %}
|
|
|
|
Settings:
|
|
|
|
Using settings module {{ settings.SETTINGS_MODULE }}{% for k, v in settings.items|dictsort:"0" %}
|
|
|
|
{{ k }} = {{ v|stringformat:"r" }}{% endfor %}
|
|
|
|
|
|
|
|
You're seeing this error because you have DEBUG = True in your
|
|
|
|
Django settings file. Change that to False, and Django will
|
2014-06-24 12:13:34 +08:00
|
|
|
display a standard page generated by the handler for this status code.
|
2011-10-02 10:53:58 +08:00
|
|
|
"""
|
|
|
|
|
2005-11-15 01:44:50 +08:00
|
|
|
TECHNICAL_404_TEMPLATE = """
|
2011-04-21 01:40:53 +08:00
|
|
|
<!DOCTYPE html>
|
2005-11-15 01:44:50 +08:00
|
|
|
<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>
|
2014-06-16 15:39:18 +08:00
|
|
|
<td>{{ request.build_absolute_uri|escape }}</td>
|
|
|
|
</tr>
|
|
|
|
{% if raising_view_name %}
|
|
|
|
<tr>
|
|
|
|
<th>Raised by:</th>
|
|
|
|
<td>{{ raising_view_name }}</td>
|
2005-11-15 01:44:50 +08:00
|
|
|
</tr>
|
2014-06-16 15:39:18 +08:00
|
|
|
{% endif %}
|
2005-11-15 01:44:50 +08:00
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div id="info">
|
2005-12-07 14:02:09 +08:00
|
|
|
{% if urlpatterns %}
|
|
|
|
<p>
|
2010-12-13 06:54:04 +08:00
|
|
|
Using the URLconf defined in <code>{{ urlconf }}</code>,
|
2005-12-07 14:02:09 +08:00
|
|
|
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
|
|
|
|
Simplified default project template.
Squashed commit of:
commit 508ec9144b35c50794708225b496bde1eb5e60aa
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 22:50:55 2013 +0100
Tweaked default settings file.
* Explained why BASE_DIR exists.
* Added a link to the database configuration options, and put it in its
own section.
* Moved sensitive settings that must be changed for production at the
top.
commit 6515fd2f1aa73a86dc8dbd2ccf512ddb6b140d57
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 14:35:21 2013 +0100
Documented the simplified app & project templates in the changelog.
commit 2c5b576c2ea91d84273a019b3d0b3b8b4da72f23
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 13:59:27 2013 +0100
Minor fixes in tutorials 5 and 6.
commit 55a51531be8104f21b3cca3f6bf70b0a7139a041
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 13:51:11 2013 +0100
Updated tutorial 2 for the new project template.
commit 29ddae87bdaecff12dd31b16b000c01efbde9e20
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 11:58:54 2013 +0100
Updated tutorial 1 for the new project template.
commit 0ecb9f6e2514cfd26a678a280d471433375101a3
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 11:29:13 2013 +0100
Adjusted the default URLconf detection to account for the admin.
It's now enabled by default.
commit 5fb4da0d3d09dac28dd94e3fde92b9d4335c0565
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 10:36:55 2013 +0100
Added security warnings for the most sensitive settings.
commit 718d84bd8ac4a42fb4b28ec93965de32680f091e
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:24:06 2013 +0100
Used an absolute path for the SQLite database.
This ensures the settings file works regardless of which directory
django-admin.py / manage.py is invoked from.
BASE_DIR got a +1 from a BDFL and another core dev. It doesn't involve
the concept of a "Django project"; it's just a convenient way to express
relative paths within the source code repository for non-Python files.
Thanks Jacob Kaplan-Moss for the suggestion.
commit 1b559b4bcda622e10909b68fe5cab90db6727dd9
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:22:40 2013 +0100
Removed STATIC_ROOT from the default settings template.
It isn't necessary in development, and it confuses beginners to no end.
Thanks Carl Meyer for the suggestion.
commit a55f141a500bb7c9a1bc259bbe1954c13b199671
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:21:43 2013 +0100
Removed MEDIA_ROOT/URL from default settings template.
Many sites will never deal with user-uploaded files, and MEDIA_ROOT is
complicated to explain.
Thanks Carl Meyer for the suggestion.
commit 44bf2f2441420fd9429ee9fe1f7207f92dd87e70
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:22:09 2013 +0100
Removed logging config.
This configuration is applied regardless of the value of LOGGING;
duplicating it in LOGGING is confusing.
commit eac747e848eaed65fd5f6f254f0a7559d856f88f
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:05:31 2013 +0100
Enabled the locale middleware by default.
USE_I18N is True by default, and doesn't work well without
LocaleMiddleware.
commit d806c62b2d00826dc2688c84b092627b8d571cab
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:03:16 2013 +0100
Enabled clickjacking protection by default.
commit 99152c30e6a15003f0b6737dc78e87adf462aacb
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:01:48 2013 +0100
Reorganized settings in logical sections, and trimmed comments.
commit d37ffdfcb24b7e0ec7cc113d07190f65fb12fb8a
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:54:11 2013 +0100
Avoided misleading TEMPLATE_DEBUG = DEBUG.
According to the docs TEMPLATE_DEBUG works only when DEBUG = True.
commit 15d9478d3a9850e85841e7cf09cf83050371c6bf
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:46:25 2013 +0100
Removed STATICFILES_FINDERS/TEMPLATE_LOADERS from default settings file.
Only developers with special needs ever need to change these settings.
commit 574da0eb5bfb4570883756914b4dbd7e20e1f61e
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:45:01 2013 +0100
Removed STATICFILES/TEMPLATES_DIRS from default settings file.
The current best practice is to put static files and templates in
applications, for easier testing and deployment.
commit 8cb18dbe56629aa1be74718a07e7cc66b4f9c9f0
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:24:16 2013 +0100
Removed settings related to email reporting from default settings file.
While handy for small scale projects, it isn't exactly a best practice.
commit 8ecbfcb3638058f0c49922540f874a7d802d864f
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 18:54:43 2013 +0100
Documented how to enable the sites framework.
commit 23fc91a6fa67d91ddd9d71b1c3e0dc26bdad9841
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:28:59 2013 +0100
Disabled the sites framework by default.
RequestSite does the job for single-domain websites.
commit c4d82eb8afc0eb8568bf9c4d12644272415e3960
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 00:08:33 2013 +0100
Added a default admin.py to the application template.
Thanks Ryan D Hiebert for the suggestion.
commit 4071dc771e5c44b1c5ebb9beecefb164ae465e22
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 10:59:49 2013 +0100
Enabled the admin by default.
Everyone uses the admin.
commit c807a31f8d89e7e7fd97380e3023f7983a8b6fcb
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 10:57:05 2013 +0100
Removed admindocs from default project template.
commit 09e4ce0e652a97da1a9e285046a91c8ad7a9189c
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:32:52 2013 +0100
Added links to the settings documentation.
commit 5b8f5eaef364eb790fcde6f9e86f7d266074cca8
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 11:06:54 2013 +0100
Used a significant example for URLconf includes.
commit 908e91d6fcee2a3cb51ca26ecdf12a6a24e69ef8
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:22:31 2013 +0100
Moved code comments about WSGI to docs, and rewrote said docs.
commit 50417e51996146f891d08ca8b74dcc736a581932
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 15:51:50 2013 +0100
Normalized the default application template.
Removed the default test that 1 + 1 = 2, because it's been committed
way too many times, in too many projects.
Added an import of `render` for views, because the first view will
often be:
def home(request):
return render(request, "mysite/home.html")
2013-01-28 22:51:50 +08:00
|
|
|
DEFAULT_URLCONF_TEMPLATE = """
|
2011-04-21 01:40:53 +08:00
|
|
|
<!DOCTYPE html>
|
2005-12-07 14:02:09 +08:00
|
|
|
<html lang="en"><head>
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
2014-05-18 06:26:46 +08:00
|
|
|
<meta name="robots" content="NONE,NOARCHIVE"><title>{{ title }}</title>
|
2005-12-07 14:02:09 +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; }
|
2014-09-04 20:15:09 +08:00
|
|
|
thead th {
|
|
|
|
padding:1px 6px 1px 3px; background:#fefefe; text-align:left;
|
|
|
|
font-weight:normal; font-size:11px; border:1px solid #ddd;
|
|
|
|
}
|
2005-12-07 14:02:09 +08:00
|
|
|
tbody th { width:12em; text-align:right; color:#666; padding-right:.5em; }
|
|
|
|
#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">
|
2014-05-18 06:26:46 +08:00
|
|
|
<h1>{{ heading }}</h1>
|
|
|
|
<h2>{{ subheading }}</h2>
|
2005-12-07 14:02:09 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="instructions">
|
Simplified default project template.
Squashed commit of:
commit 508ec9144b35c50794708225b496bde1eb5e60aa
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 22:50:55 2013 +0100
Tweaked default settings file.
* Explained why BASE_DIR exists.
* Added a link to the database configuration options, and put it in its
own section.
* Moved sensitive settings that must be changed for production at the
top.
commit 6515fd2f1aa73a86dc8dbd2ccf512ddb6b140d57
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 14:35:21 2013 +0100
Documented the simplified app & project templates in the changelog.
commit 2c5b576c2ea91d84273a019b3d0b3b8b4da72f23
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 13:59:27 2013 +0100
Minor fixes in tutorials 5 and 6.
commit 55a51531be8104f21b3cca3f6bf70b0a7139a041
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 13:51:11 2013 +0100
Updated tutorial 2 for the new project template.
commit 29ddae87bdaecff12dd31b16b000c01efbde9e20
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 11:58:54 2013 +0100
Updated tutorial 1 for the new project template.
commit 0ecb9f6e2514cfd26a678a280d471433375101a3
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 11:29:13 2013 +0100
Adjusted the default URLconf detection to account for the admin.
It's now enabled by default.
commit 5fb4da0d3d09dac28dd94e3fde92b9d4335c0565
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 10:36:55 2013 +0100
Added security warnings for the most sensitive settings.
commit 718d84bd8ac4a42fb4b28ec93965de32680f091e
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:24:06 2013 +0100
Used an absolute path for the SQLite database.
This ensures the settings file works regardless of which directory
django-admin.py / manage.py is invoked from.
BASE_DIR got a +1 from a BDFL and another core dev. It doesn't involve
the concept of a "Django project"; it's just a convenient way to express
relative paths within the source code repository for non-Python files.
Thanks Jacob Kaplan-Moss for the suggestion.
commit 1b559b4bcda622e10909b68fe5cab90db6727dd9
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:22:40 2013 +0100
Removed STATIC_ROOT from the default settings template.
It isn't necessary in development, and it confuses beginners to no end.
Thanks Carl Meyer for the suggestion.
commit a55f141a500bb7c9a1bc259bbe1954c13b199671
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:21:43 2013 +0100
Removed MEDIA_ROOT/URL from default settings template.
Many sites will never deal with user-uploaded files, and MEDIA_ROOT is
complicated to explain.
Thanks Carl Meyer for the suggestion.
commit 44bf2f2441420fd9429ee9fe1f7207f92dd87e70
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:22:09 2013 +0100
Removed logging config.
This configuration is applied regardless of the value of LOGGING;
duplicating it in LOGGING is confusing.
commit eac747e848eaed65fd5f6f254f0a7559d856f88f
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:05:31 2013 +0100
Enabled the locale middleware by default.
USE_I18N is True by default, and doesn't work well without
LocaleMiddleware.
commit d806c62b2d00826dc2688c84b092627b8d571cab
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:03:16 2013 +0100
Enabled clickjacking protection by default.
commit 99152c30e6a15003f0b6737dc78e87adf462aacb
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:01:48 2013 +0100
Reorganized settings in logical sections, and trimmed comments.
commit d37ffdfcb24b7e0ec7cc113d07190f65fb12fb8a
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:54:11 2013 +0100
Avoided misleading TEMPLATE_DEBUG = DEBUG.
According to the docs TEMPLATE_DEBUG works only when DEBUG = True.
commit 15d9478d3a9850e85841e7cf09cf83050371c6bf
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:46:25 2013 +0100
Removed STATICFILES_FINDERS/TEMPLATE_LOADERS from default settings file.
Only developers with special needs ever need to change these settings.
commit 574da0eb5bfb4570883756914b4dbd7e20e1f61e
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:45:01 2013 +0100
Removed STATICFILES/TEMPLATES_DIRS from default settings file.
The current best practice is to put static files and templates in
applications, for easier testing and deployment.
commit 8cb18dbe56629aa1be74718a07e7cc66b4f9c9f0
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:24:16 2013 +0100
Removed settings related to email reporting from default settings file.
While handy for small scale projects, it isn't exactly a best practice.
commit 8ecbfcb3638058f0c49922540f874a7d802d864f
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 18:54:43 2013 +0100
Documented how to enable the sites framework.
commit 23fc91a6fa67d91ddd9d71b1c3e0dc26bdad9841
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:28:59 2013 +0100
Disabled the sites framework by default.
RequestSite does the job for single-domain websites.
commit c4d82eb8afc0eb8568bf9c4d12644272415e3960
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 00:08:33 2013 +0100
Added a default admin.py to the application template.
Thanks Ryan D Hiebert for the suggestion.
commit 4071dc771e5c44b1c5ebb9beecefb164ae465e22
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 10:59:49 2013 +0100
Enabled the admin by default.
Everyone uses the admin.
commit c807a31f8d89e7e7fd97380e3023f7983a8b6fcb
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 10:57:05 2013 +0100
Removed admindocs from default project template.
commit 09e4ce0e652a97da1a9e285046a91c8ad7a9189c
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:32:52 2013 +0100
Added links to the settings documentation.
commit 5b8f5eaef364eb790fcde6f9e86f7d266074cca8
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 11:06:54 2013 +0100
Used a significant example for URLconf includes.
commit 908e91d6fcee2a3cb51ca26ecdf12a6a24e69ef8
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:22:31 2013 +0100
Moved code comments about WSGI to docs, and rewrote said docs.
commit 50417e51996146f891d08ca8b74dcc736a581932
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 15:51:50 2013 +0100
Normalized the default application template.
Removed the default test that 1 + 1 = 2, because it's been committed
way too many times, in too many projects.
Added an import of `render` for views, because the first view will
often be:
def home(request):
return render(request, "mysite/home.html")
2013-01-28 22:51:50 +08:00
|
|
|
<p>
|
2014-06-12 14:37:21 +08:00
|
|
|
{{ instructions|safe }}
|
Simplified default project template.
Squashed commit of:
commit 508ec9144b35c50794708225b496bde1eb5e60aa
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 22:50:55 2013 +0100
Tweaked default settings file.
* Explained why BASE_DIR exists.
* Added a link to the database configuration options, and put it in its
own section.
* Moved sensitive settings that must be changed for production at the
top.
commit 6515fd2f1aa73a86dc8dbd2ccf512ddb6b140d57
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 14:35:21 2013 +0100
Documented the simplified app & project templates in the changelog.
commit 2c5b576c2ea91d84273a019b3d0b3b8b4da72f23
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 13:59:27 2013 +0100
Minor fixes in tutorials 5 and 6.
commit 55a51531be8104f21b3cca3f6bf70b0a7139a041
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 13:51:11 2013 +0100
Updated tutorial 2 for the new project template.
commit 29ddae87bdaecff12dd31b16b000c01efbde9e20
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 11:58:54 2013 +0100
Updated tutorial 1 for the new project template.
commit 0ecb9f6e2514cfd26a678a280d471433375101a3
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 11:29:13 2013 +0100
Adjusted the default URLconf detection to account for the admin.
It's now enabled by default.
commit 5fb4da0d3d09dac28dd94e3fde92b9d4335c0565
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 10:36:55 2013 +0100
Added security warnings for the most sensitive settings.
commit 718d84bd8ac4a42fb4b28ec93965de32680f091e
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:24:06 2013 +0100
Used an absolute path for the SQLite database.
This ensures the settings file works regardless of which directory
django-admin.py / manage.py is invoked from.
BASE_DIR got a +1 from a BDFL and another core dev. It doesn't involve
the concept of a "Django project"; it's just a convenient way to express
relative paths within the source code repository for non-Python files.
Thanks Jacob Kaplan-Moss for the suggestion.
commit 1b559b4bcda622e10909b68fe5cab90db6727dd9
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:22:40 2013 +0100
Removed STATIC_ROOT from the default settings template.
It isn't necessary in development, and it confuses beginners to no end.
Thanks Carl Meyer for the suggestion.
commit a55f141a500bb7c9a1bc259bbe1954c13b199671
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 23:21:43 2013 +0100
Removed MEDIA_ROOT/URL from default settings template.
Many sites will never deal with user-uploaded files, and MEDIA_ROOT is
complicated to explain.
Thanks Carl Meyer for the suggestion.
commit 44bf2f2441420fd9429ee9fe1f7207f92dd87e70
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:22:09 2013 +0100
Removed logging config.
This configuration is applied regardless of the value of LOGGING;
duplicating it in LOGGING is confusing.
commit eac747e848eaed65fd5f6f254f0a7559d856f88f
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:05:31 2013 +0100
Enabled the locale middleware by default.
USE_I18N is True by default, and doesn't work well without
LocaleMiddleware.
commit d806c62b2d00826dc2688c84b092627b8d571cab
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:03:16 2013 +0100
Enabled clickjacking protection by default.
commit 99152c30e6a15003f0b6737dc78e87adf462aacb
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 22:01:48 2013 +0100
Reorganized settings in logical sections, and trimmed comments.
commit d37ffdfcb24b7e0ec7cc113d07190f65fb12fb8a
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:54:11 2013 +0100
Avoided misleading TEMPLATE_DEBUG = DEBUG.
According to the docs TEMPLATE_DEBUG works only when DEBUG = True.
commit 15d9478d3a9850e85841e7cf09cf83050371c6bf
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:46:25 2013 +0100
Removed STATICFILES_FINDERS/TEMPLATE_LOADERS from default settings file.
Only developers with special needs ever need to change these settings.
commit 574da0eb5bfb4570883756914b4dbd7e20e1f61e
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:45:01 2013 +0100
Removed STATICFILES/TEMPLATES_DIRS from default settings file.
The current best practice is to put static files and templates in
applications, for easier testing and deployment.
commit 8cb18dbe56629aa1be74718a07e7cc66b4f9c9f0
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:24:16 2013 +0100
Removed settings related to email reporting from default settings file.
While handy for small scale projects, it isn't exactly a best practice.
commit 8ecbfcb3638058f0c49922540f874a7d802d864f
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 18:54:43 2013 +0100
Documented how to enable the sites framework.
commit 23fc91a6fa67d91ddd9d71b1c3e0dc26bdad9841
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:28:59 2013 +0100
Disabled the sites framework by default.
RequestSite does the job for single-domain websites.
commit c4d82eb8afc0eb8568bf9c4d12644272415e3960
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Tue Jan 29 00:08:33 2013 +0100
Added a default admin.py to the application template.
Thanks Ryan D Hiebert for the suggestion.
commit 4071dc771e5c44b1c5ebb9beecefb164ae465e22
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 10:59:49 2013 +0100
Enabled the admin by default.
Everyone uses the admin.
commit c807a31f8d89e7e7fd97380e3023f7983a8b6fcb
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 10:57:05 2013 +0100
Removed admindocs from default project template.
commit 09e4ce0e652a97da1a9e285046a91c8ad7a9189c
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:32:52 2013 +0100
Added links to the settings documentation.
commit 5b8f5eaef364eb790fcde6f9e86f7d266074cca8
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 11:06:54 2013 +0100
Used a significant example for URLconf includes.
commit 908e91d6fcee2a3cb51ca26ecdf12a6a24e69ef8
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 16:22:31 2013 +0100
Moved code comments about WSGI to docs, and rewrote said docs.
commit 50417e51996146f891d08ca8b74dcc736a581932
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date: Mon Jan 28 15:51:50 2013 +0100
Normalized the default application template.
Removed the default test that 1 + 1 = 2, because it's been committed
way too many times, in too many projects.
Added an import of `render` for views, because the first view will
often be:
def home(request):
return render(request, "mysite/home.html")
2013-01-28 22:51:50 +08:00
|
|
|
</p>
|
2005-12-07 14:02:09 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="explanation">
|
|
|
|
<p>
|
2014-06-12 14:37:21 +08:00
|
|
|
{{ explanation|safe }}
|
2005-12-07 14:02:09 +08:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</body></html>
|
|
|
|
"""
|