定制404、500页面
1.
首先将settings设置debug=false。
2.
STATICFILES_DIRS = (
'static',
os.path.join(os.path.dirname(__file__), '..', 'static'),
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
3.
STATIC_URL = '/static/'
4.
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
或者
url(r'^(?P<path>.*)$','django.views.static.serve',{'document_root':settings.STATIC_ROOT}),
5.
将自定义的400.html和500.html放到根模板下。
6.
随便输入一个错误的地址,将显示你自定义的错误页面。