简体   繁体   中英

django-pipeline amazon s3 collectstatic file could not be found

I am using s3boto, django-pipeline and django-storages with this setting:

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATICFILES_STORAGE = 'utils.classutils.S3PipelineStorage'

MEDIA_ROOT = "/"
MEDIA_URL = '//s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
STATIC_ROOT = '/static/'
STATIC_URL = '//s3.amazonaws.com/%s/static/' % AWS_STORAGE_BUCKET_NAME
STATICFILES_DIRS = (
    os.path.join(SITE_ROOT, 'assets'),
)

and this custom storage for django-pipeline

from django.contrib.staticfiles.storage import CachedFilesMixin
from pipeline.storage import PipelineMixin
from storages.backends.s3boto import S3BotoStorage

class S3PipelineStorage(PipelineMixin, CachedFilesMixin, S3BotoStorage):
    pass

but I keep on getting:

ValueError: The file 'project/head.png' could not be found with <utils.classutils.S3PipelineStorage object at 0x2163510>.

but this file does not exist anywhere! not in plugins, I tried finding it, I checked my static dirs, tried finding it in admin, and I don't even remember working with a file named like this! I tried findstatic and the file can't be found.

What could I be missing?

你当然有一个css文件,指向一个不存在的'project/head.png'文件,删除此引用,它应该工作。

Short tip. I encountered this when I was setting up S3 for serving static files.

I wanted to serve static content from s3 and keep handling uploaded files to the media folder on the local machine. What I had then was one image that was referenced in a css-file on s3 that was pointing to an image in the media folder like this background: url(../media/some/image.png) .

Obviously that file could not be found in s3 with the relative path that was set in the css and the upload crashed. It works locally but not when running staticfiles from s3.

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