简体   繁体   English

在Heroku上提供Django静态文件

[英]Serving Django static files on Heroku

I'm having an odd issue when porting my Django site from dev server to Heroku. 将我的Django网站从开发服务器移植到Heroku时遇到一个奇怪的问题。 I know I'm not supposed to use django to directly serve the static files, but I'm just testing out an idea for now. 我知道我不应该使用django直接提供静态文件,但是我现在只是测试一个想法。

I've tried using: 我试过使用:

from django.contrib.staticfiles.urls import staticfiles_urlpatterns
    urlpatterns += staticfiles_urlpatterns()

as well as: 以及:

from django.conf import settings
    urlpatterns += patterns(
        (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),)

but with either solution I my .css files get served just fine but my .png image files do not. 但是无论使用哪种解决方案,我的.css文件都可以正常使用,但我的.png图像文件却不能。 Is there any reason these files would be different with respect to how Django and Heroku handle them? 这些文件在Django和Heroku处理方式方面是否有任何不同的原因?

It was the upper-lower case issue. 这是大小写问题。 It turns out the filename had one more cap letter than the reference in the html file... Always an issue when I move from Mac OS to case sensitive Unix. 事实证明,文件名比html文件中的引用多了一个大写字母...从Mac OS转到区分大小写的Unix时,这始终是一个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM