在Django中,DEBUG = True和False之间的功能区别是什么? [英] What are functional differences between DEBUG = True and False in Django?
问题描述
在Django应用的settings.py文件中切换 DEBUG
设置之间到底有什么功能差异?
我首先假定 DEBUG = True
仅打开了Django的日志记录功能和中间件以进行错误报告,但是现在解决方案
-
DEBUG = True
,如果有错误,页面将显示错误的详细信息. -
如果
DEBUG = False
,则settings.py
的ALLOWED_HOSTS
将正常工作,则应谨慎设置./p> -
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
The
DEBUG=True
, if there is error, page will show details of error.if
DEBUG=False
, theALLOWED_HOSTS
ofsettings.py
will work, you should take carefully to set it.the
media
andstatic
will not provide access forDEBUG=False
, you have to provide them with the help of webserver, likeNginx
orApache
.
这篇关于在Django中,DEBUG = True和False之间的功能区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!