每次刷新都会添加更多的尾部斜杠 - Django

时间:2013-03-30 06:34:01

标签: django django-urls django-settings

我正在使用django 1.3.1,在我的应用程序中,我在settings.py中设置了DEBUG = False。当我刷新页面时,url会进入一些循环过程,并且在每个循环中都会将斜杠附加到静态文件中,因此不会调用静态文件。我在下面粘贴了一个示例终端输出。可能是什么原因,我该如何解决这个问题?

[30/Mar/2013 11:57:30] "GET /static/img/admin/logo.jpg//////// HTTP/1.1" 301 0
[30/Mar/2013 11:57:30] "GET /static/img/admin/logo.jpg///////// HTTP/1.1" 301 0
[30/Mar/2013 11:57:30] "GET /static/img/admin/logo.jpg////////// HTTP/1.1" 301 0
[30/Mar/2013 11:57:30] "GET /static/img/admin/logo.jpg/////////// HTTP/1.1" 301 0
[30/Mar/2013 11:57:30] "GET /static/img/admin/logo.jpg//////////// HTTP/1.1" 301 0
[30/Mar/2013 11:57:30] "GET /static/img/admin/logo.jpg///////////// HTTP/1.1" 301 0
[30/Mar/2013 11:57:30] "GET /static/img/admin/logo.jpg////////////// HTTP/1.1" 301 0
[30/Mar/2013 11:57:30] "GET /static/img/admin/logo.jpg/////////////// HTTP/1.1" 301 0
[30/Mar/2013 11:57:30] "GET /static/img/admin/logo.jpg//////////////// HTTP/1.1" 301 0
[30/Mar/2013 11:57:31] "GET /static/img/admin/logo.jpg///////////////// HTTP/1.1" 301 0
[30/Mar/2013 11:57:31] "GET /static/img/admin/logo.jpg////////////////// HTTP/1.1" 301 0
[30/Mar/2013 11:57:31] "GET /static/img/admin/logo.jpg/////////////////// HTTP/1.1" 301 0

当我在settings.py中设置DEBUG = True时,此功能正常。

1 个答案:

答案 0 :(得分:0)

经过一番搜索后,我发现这个问题非常有用。 Why does DEBUG=False setting make my django Static Files Access fail?

  

关闭调试后,Django将不再为您处理静态文件 - 您的生产Web服务器(Apache或其他东西)应该处理这个问题。

     

如果您仍需要本地服务器静态(例如,无需调试进行测试),您可以在不安全模式下运行devserver:manage.py runserver --insecure