首页 > 其他 > 详细

定制404、500页面

时间:2014-07-21 14:33:17      阅读:312      评论:0      收藏:0      [点我收藏+]

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.
随便输入一个错误的地址,将显示你自定义的错误页面。

定制404、500页面,布布扣,bubuko.com

定制404、500页面

原文:http://www.cnblogs.com/tuifeideyouran/p/3858095.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!