我在CentOS上部署了一个Django应用程序.这是我的httpd.conf文件的样子:
WSGISocketPrefix /var/run/wsgi
<VirtualHost *:80>
WSGIDaemonProcess safe python-path=/usr/lib/python2.6/site-packages
WSGIProcessGroup safe
WSGIScriptAlias / /opt/safe/safe/wsgi.py
<Directory /opt/safe/safe/>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
编辑:这是我的 TEMPLATE_DIRS
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
"/opt/safe/static/templates",
"/var/www/html/static/templates",
)
Run Code Online (Sandbox Code Playgroud)
编辑:这是我的管理员/电子邮件设置:
ADMINS = (
# ('Your Name', 'your_email@example.com'),
('David', 'david@localhost'),
)
SEND_BROKEN_LINK_EMAILS = True
DEFAULT_FROM_EMAIL = 'david@localhost'
SERVER_EMAIL = DEFAULT_FROM_EMAIL
Run Code Online (Sandbox Code Playgroud)
在我的模板目录中,我已经定义了一个自定义500.html文件.当我设置我settings.py …
DEBUG在 Django 应用程序的 settings.py 文件中切换设置之间的功能差异究竟是什么?
我一开始以为DEBUG=True只是打开了 Django 的日志记录功能和中间件来报告错误,但现在我意识到我太天真了。了解 Django 内部系统在两种布尔设置下的工作方式有何不同,有助于在处理难以调试的普通状态 500 错误时形成假设
Windows 7
Python 2.7.3
Django 1.5
python manage.py runserver
我正在关注" https://docs.djangoproject.com/en/1.5/intro/tutorial03/ "上提供的教程.
在settings.py中使用DEBUG = True可以正确生成网页.地址
http://127.0.0.1:8000/admin/
Run Code Online (Sandbox Code Playgroud)
显示管理员登录页面.
http://127.0.0.1:8000/polls/
Run Code Online (Sandbox Code Playgroud)
显示'什么事?' 项目符号链接.
http://127.0.0.1:8000/polls/1/
Run Code Online (Sandbox Code Playgroud)
显示数字'1'
http://127.0.0.1:8000/polls/2/
Run Code Online (Sandbox Code Playgroud)
显示标准404消息.但是,如果我设置DEBUG = False(并且不执行任何其他操作),那么我在所有地址都会出现500错误!我正在使用开发内部运行服务器.没有回溯错误.服务器日志如下所示:
DEBUG = True
0 errors found
March 19, 2013 - 12:01:12
Django version 1.5, using settings 'mysite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[19/Mar/2013 12:06:41] "GET /admin/ HTTP/1.1" 200 1893
[19/Mar/2013 12:54:55] "GET /polls/ HTTP/1.1" 200 74
[19/Mar/2013 12:55:02] "GET /polls/2/ HTTP/1.1" 404 1577
[19/Mar/2013 12:55:09] "GET /polls/1/ HTTP/1.1" …Run Code Online (Sandbox Code Playgroud)