在Django中,DEBUG = True和False之间的功能区别是什么? [英] What are functional differences between DEBUG = True and False in Django?

查看:98
本文介绍了在Django中,DEBUG = True和False之间的功能区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Django应用的settings.py文件中切换 DEBUG 设置之间到底有什么功能差异?

我首先假定 DEBUG = True 仅打开了Django的日志记录功能和中间件以进行错误报告,但是现在解决方案

  1. DEBUG = True ,如果有错误,页面将显示错误的详细信息.

  2. 如果 DEBUG = False ,则 settings.py ALLOWED_HOSTS 将正常工作,则应谨慎设置./p>

  3. media static 将不提供对 DEBUG = False 的访问,您必须向他们提供网络服务器的帮助,例如 Nginx Apache .

What precisely are the functional differences between toggling the DEBUG setting in a settings.py file of a Django app?

I first assumed DEBUG=True merely turned on Django's logging capability and middleware for error reporting, but now I realize that was naive of me. Understanding how the Django internal systems work differently under the two boolean settings helps to form hypotheses when dealing with difficult to debug, plain status 500 errors

解决方案

  1. The DEBUG=True, if there is error, page will show details of error.

  2. if DEBUG=False, the ALLOWED_HOSTS of settings.py will work, you should take carefully to set it.

  3. the media and static will not provide access for DEBUG=False, you have to provide them with the help of webserver, like Nginx or Apache.

这篇关于在Django中,DEBUG = True和False之间的功能区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆