如果我直接从命令行执行runserver或gunicorn,网站就能正常工作。但是,如果我尝试使用Heroku documentation中指定的Foreman运行gunicorn:
web: gunicorn myapp.wsgi然后我的网站的静态文件突然变得不可访问;尝试转到
http://0.0.0.0:5000/static/js/jquery-1.9.1.min.js只给出这条错误消息:
Using the URLconf defined in myapp.urls, Django tried these URL patterns, in this order:
^$ [name='homepage']
...
The current URL, static/js/jquery-1.9.1.min.js, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.正如我已经说过的,如果直接调用gunicorn或runserver,或者即使在foreman start中使用runserver,静态文件肯定是可以访问的,所以我猜这与我的静态文件设置没有太多关系?
此外,使用DEBUG = False在foreman上运行gunicorn甚至不会返回任何东西,只返回一个500错误。没有记录任何东西,甚至在Sentry上也没有,所以我不知道出了什么问题。单独使用gunicorn或runserver,或者将runserver与foreman一起使用也可以很好地工作。
你知道我能做什么来解决这个问题吗?
发布于 2013-04-10 16:18:48
我不知道为什么没有检索静态文件,但DEBUG = False 500错误只是由我的ALLOWED_HOSTS设置引起的,修复它没有产生更多的问题。
发布于 2013-04-08 15:04:15
我会尝试打印出设置,同时在gunicorn下运行,并查看您的媒体URL是否正确,以及js文件是否确实可访问。
至于500错误,它可能试图向你显示404页面,但你没有它的模板,所以它引发了500,和旧的django quirk ;)
PS。这一切都是假设您验证了在该错误中具有正确的URL模式
https://stackoverflow.com/questions/15872675
复制相似问题