简体   繁体   中英

Serving Django static files on Heroku

I'm having an odd issue when porting my Django site from dev server to 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.

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. Is there any reason these files would be different with respect to how Django and Heroku handle them?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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