开发者

Django gets really slow when DEBUG = False

开发者 https://www.devze.com 2023-01-30 09:40 出处:网络
I\'ve got a Django application that\'s running fine in debug mode. By \"running fine\" I mean no errors and \"near instant\" page loads. When I turn debug mode off by setting DEBUG = False, page loads

I've got a Django application that's running fine in debug mode. By "running fine" I mean no errors and "near instant" page loads. When I turn debug mode off by setting DEBUG = False, page loads become very slow, typically 60-80 seconds per page.

No other changes were made, and no errors appear开发者_StackOverflow社区 in the logs.

I'm using the development web server and SQLite.


Well, be sure that you are not using IPv6. Because I got this same problem with you.

Just don't use localhost:8000, instead, using 127.0.0.1:8000.

Be sure you make changes to the listening address and port in django .


In the end I believe the problem I was having was related to the way static media files are served by the Django dev server and following setting which is in my urls.py:

if settings.DEBUG: urlpatterns += patterns('', (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), )

I fixed this by getting apache and mod_wsgi set up on the staging server and not using the dev server when debug mode is off.

0

精彩评论

暂无评论...
验证码 换一张
取 消