Django Compressor和S3 OfflineGenerationError

时间:2015-02-05 19:48:21

标签: django heroku amazon-s3 django-compressor

我设法将Django压缩器配置为在本地工作,但我在生产服务器(heroku)上苦苦挣扎。首先,这是我的settings.py

COMPRESS_PRECOMPILERS = (
    ('text/less', 'lessc {infile} {outfile}'),
)
STATIC_URL = '/static/'

STATIC_ROOT = 'staticfiles'

STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)

STATICFILES_FINDERS = (
                       "django.contrib.staticfiles.finders.FileSystemFinder",
                       "django.contrib.staticfiles.finders.AppDirectoriesFinder",
                       "compressor.finders.CompressorFinder",
                       )
#Amazon S3
AWS_STORAGE_BUCKET_NAME = get_env_variable('AWS_STATIC_BUCKET_NAME')
AWS_ACCESS_KEY_ID = get_env_variable('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = get_env_variable('AWS_SECRET_ACCESS_KEY')
DEFAULT_FILE_STORAGE = 's3utils.MediaRootS3BotoStorage'
AWS_S3_FILE_OVERWRITE = False
AWS_MEDIA_BUCKET_NAME = get_env_variable('AWS_MEDIA_BUCKET_NAME')
AWS_STATIC_BUCKET_NAME = get_env_variable('AWS_STATIC_BUCKET_NAME')
STATICFILES_STORAGE = 's3utils.StaticRootS3BotoStorage'
#Compressor
COMPRESS_STORAGE = STATICFILES_STORAGE
COMPRESS_OFFLINE = True
COMPRESS_ROOT = BASE_DIR
COMPRESS_URL = get_env_variable('AWS_BASE_URL')
STATIC_URL = COMPRESS_URL
COMPRESS_ENABLED = True 

s3utils.py

from django.conf import settings
from django.core.files.storage import get_storage_class
from storages.backends.s3boto import S3BotoStorage

MediaRootS3BotoStorage  = lambda: S3BotoStorage(bucket=settings.AWS_MEDIA_BUCKET_NAME)


class StaticRootS3BotoStorage(S3BotoStorage):
    """
    S3 storage backend that saves the files locally, too.
    """
    def __init__(self, *args, **kwargs):
        super(StaticRootS3BotoStorage, self).__init__(*args, **kwargs)
        self.local_storage = get_storage_class(
            "compressor.storage.CompressorFileStorage")()
        self.location='/static/'
        self.bucket_name=settings.AWS_STATIC_BUCKET_NAME

    def save(self, name, content):
        name = super(StaticRootS3BotoStorage, self).save(name, content)
        self.local_storage._save(name, content)
        return name

这是我的base.html模板,项目中的所有其他模板都使用该模板,这是我拥有{% compress %}标记的唯一位置。

{% if debug %}
   <link rel="stylesheet" type="text/less" media="all" href="{% static 'less/master.less' %}" />
   <script src="{% static 'libs/less/js/less.min.js' %}"></script>
{% else %}
   {% compress css %}
      <link rel="stylesheet" type="text/less" media="all" href="{% static 'less/elements.less' %}" />
      <link rel="stylesheet" type="text/less" media="all" href="{% static 'less/responsive-alignment.less' %}" />
   {% endcompress %}
{% endif %}

当我进行部署时,这是输出:

-----> Running run_compress
-----> Compressing static files
       Found 'compress' tags in:
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/email.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/password_change.html
        /app/templates/account/verification_sent.html
        /app/profileApp/templates/profileApp/user-profile.html
        /app/templates/base.html
        /app/templates/socialaccount/connections.html
        /app/templates/account/password_reset_from_key_done.html
        /app/templates/account/signup.html
        /app/templates/account/password_reset.html
        /app/templates/account/verified_email_required.html
        /app/profileApp/templates/profileApp/upload_picture.html
        /app/templates/account/password_change.html
        /app/templates/account/account_inactive.html
        /app/templates/openid/login.html
        /app/templates/account/base.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/base.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/password_reset.html
        /app/picturesApp/templates/picturesApp/home.html
        /app/templates/openid/base.html
        /app/picturesApp/templates/picturesApp/gallery.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/signup_closed.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/openid/login.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/socialaccount/signup.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/verified_email_required.html
        /app/templates/account/email.html
        /app/templates/account/password_set.html
        /app/templates/account/password_reset_done.html
        /app/picturesApp/templates/picturesApp/base/base.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/socialaccount/authentication_error.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/email_confirmed.html
        /app/templates/socialaccount/authentication_error.html
        /app/profileApp/templates/profileApp/base/base.html
        /app/templates/account/signup_closed.html
        /app/templates/socialaccount/login_cancelled.html
        /app/templates/account/email_confirm.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/login.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/password_reset_from_key.html
        /app/templates/account/email_confirmed.html
        /app/profileApp/templates/profileApp/account-info.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/password_set.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/signup.html
        /app/templates/account/logout.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/socialaccount/connections.html
        /app/templates/account/login.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/socialaccount/base.html
        /app/templates/account/password_reset_from_key.html
        /app/templates/socialaccount/signup.html
        /app/templates/socialaccount/base.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/password_reset_done.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/socialaccount/login_cancelled.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/openid/base.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/password_reset_from_key_done.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/logout.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/email_confirm.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/account_inactive.html
        /app/.heroku/python/lib/python2.7/site-packages/allauth/templates/account/verification_sent.html
       Compressing... done
       Compressed 56 block(s) from 56 template(s).

然后,如果我查看S3存储桶,在CACHE文件夹中,我有manifest.json这个内容:

{
  "6cf537e53fed2bfec81d3959dc94c467": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=8uuAEVs1mpweRfKciBs16B%2BZyPk%3D&Expires=1423168563&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "5d2dfc90970dbde0ef4f96661f8ae5d8": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=lruWG1Ym3GgKbNF91hAV1Bkq8%2BE%3D&Expires=1423168564&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "443afda7fbc46fef06f151b8cf7bf3c8": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=LjEhp8nPsjWwSETVJeL0jtRFAfk%3D&Expires=1423168565&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "e1ebba561b757875b9b674b5a9399445": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=ofqkHRM%2FWj%2FF6bVar1Lp5blmXXw%3D&Expires=1423168566&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "66bc085ab04e00f0e6001df0e91997e4": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=aF5%2F5o45VhNV%2F5K9NzSCLqQGZso%3D&Expires=1423168567&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "87e5547fa62d1507e502b815e4b9386b": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=%2BNerYhgjuj5nMiT6CLlZVGIsYUw%3D&Expires=1423168568&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "ffedfd1c56d0ef189f02048eb5a3fd2a": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=ph%2BE2hrGSo4bpC61IaU0n0e2ZEM%3D&Expires=1423168569&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "f186a8be52546fc9e8b995d97b24b97d": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=mWS2OiAvjFG18xBBIfb1E1LIJ24%3D&Expires=1423168570&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "2615908914f5583c67bbfbd9fa50a047": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=xBrlPBWWljxtg2pnVngihauyshk%3D&Expires=1423168571&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "134db382afc33c72396d10e57ec4ae8d": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=0X1Ibh%2Fo12RSy%2FoZMZ859g6Gd8Q%3D&Expires=1423168572&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "ff75d77bf2ea3ad9711c10ee04158d8e": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=wSYse9o60aQl5842hda%2FaVGb4hw%3D&Expires=1423168573&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "9c049c408bf137ecf25e8beaf79bbc3d": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=pVKMqQHS%2BiZ9SIIgu2c1o1dhvpA%3D&Expires=1423168574&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "d4c746fec6f5d7b9d4a78c862e585aa0": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=xjNHm0723E5EYr1zsit%2FWxLW4Fg%3D&Expires=1423168575&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "0fe9f2e0f0fe585cf96e359e4f7ee1d8": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=lXVR3cx1gLEDjmrGn8ZdCvszoTg%3D&Expires=1423168576&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "bc0893892965f1e42ffc3a851ef087aa": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=zOXtAoQk30gpIbNAcYfV4XXfFLE%3D&Expires=1423168577&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "6b1f25d2033c12538e8856cadd9dd761": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=hmYinWJIugzFVrfL%2BjwpJEsr8MM%3D&Expires=1423168578&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "68f7f867da8268acf60c45426a9529e7": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=6vQyZOZjy44JFOhZoGtUdha0JDs%3D&Expires=1423168579&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "86e2f2676ddf752c658fc9fcc8653b89": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=bAe0ZBIWOht3FvD6dVO%2BBPI30sI%3D&Expires=1423168580&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "ccf58e48da2c07e3b226740cf9edb005": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=62w3Yh1GGQMKmgnMoM4jcezwzMo%3D&Expires=1423168581&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "533d988f2100e1bdcdd8356c63e928e4": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=%2B7Omwy92j3wu1GPxJALFg%2BibET8%3D&Expires=1423168582&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "1894dec27b27ee5f84f0063d5ca3fc1a": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=KClME28nhqBalUKhSjjQs97RXck%3D&Expires=1423168583&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "d2691e513fb4a864c6a3ed86257f4849": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=oeGUkwHTXFoQzWVp0S6w8%2FsjxW8%3D&Expires=1423168584&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "5ee48d5d0a6d2e4b9758cb575fb09db5": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=0m6DYA7gaMcvzto1zBQ9zMR1tx8%3D&Expires=1423168585&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "4935237509f7d36cd8c3894ef0fa6318": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=19PvR51axQRK7Or7ctnXcm3gZ7k%3D&Expires=1423168587&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "bef4d1a5611c53d12d63ca912a522b94": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=tBe0PqjEriZnHQf6Et6ePzM9LMg%3D&Expires=1423168588&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "a55bf26bebd17b2eb1923d0f2fd6f431": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=giUXWQLG79nFa8QRTn9up0T2mnc%3D&Expires=1423168589&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "6ee9592301d1fd38ab53dce848ca966c": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=VZcftSspdjp3aHO16DNYFBWzqGQ%3D&Expires=1423168590&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "ebb07be60ac1330f0ee2044e287a2417": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=FqxFsf9Ht%2Bo7%2BfgInPw9YLeJPLo%3D&Expires=1423168591&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "9e0c024dd1b68e7deb5c92984c91b811": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=Tpw5eoP2J10F9QPRtZL9fpSView%3D&Expires=1423168592&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "fd3d5d0397691948163b581ce4c8c2b0": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=BnmmOIs4QfSSJZ0YyxZlMHONmNo%3D&Expires=1423168593&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "fe7512f6c1691d37d243bc92e7043bc2": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=xJ6bGq6wdD6iP3KcOR2ct6Mub9c%3D&Expires=1423168594&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "94673f5266d484c4721632eef00f18ed": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=fFMd3nmbaAPOxvNx2s4jMWKu7w4%3D&Expires=1423168595&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "7f58edd97921b4af0cc1880c8a0598b2": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=TsOPytLVQ4fzSTmgHGDNNtbLCn4%3D&Expires=1423168596&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "60fa27c1952b4d80d6f2960055ca8b75": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=mDKx1A3AFT24aPvtLy29%2F79b0AU%3D&Expires=1423168597&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "bceb9f1af8b15c56e555ef60d0568474": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=A1YW5TTU3zX%2B%2FVaarWZR6wJWYDg%3D&Expires=1423168598&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "27d8054f6a2689a6a7a3e1ddd40499e4": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=%2FuV8x3wl6hEdgM8dKKZk7wP00CE%3D&Expires=1423168599&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "60b5a73c73c4919a90e613377d0dd185": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=Wt1XEldz588F2ifV3kLIKV6goeE%3D&Expires=1423168600&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "0a9a77ec33a534e69f7ae8daa0a70291": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=ndhmMw1TWTf8e%2FQcWzfVtVOwaM4%3D&Expires=1423168601&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "16c369a9af6dfe2b2496c612bc98e2c0": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=3sL%2FJCkDcNIz%2BY34Im59hGaGjvs%3D&Expires=1423168602&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "802bbdd1008f174507fca653702218ee": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=U87o20IorgRGmJqlblbHu5vJKsM%3D&Expires=1423168603&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "bae967afb459db9f85f21fef39167e2b": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=1ErbWrV2nxBKzefp%2F%2FK4fbbHB14%3D&Expires=1423168605&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "0ec51ed04b5262047df18986a6f9bc4a": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=zYV2tI6AYMbGtmvGwttwhX9k7xg%3D&Expires=1423168606&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "218e55c6714e24d2622a038c9acb91bf": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=VwNG97cD76qz839n%2FMHUtdbv2QQ%3D&Expires=1423168607&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "bf20d24e464e7b53e50f3dce8a25b332": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=Bme7ovtFpQLAK0S1k49C4renl3c%3D&Expires=1423168608&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "038b769ab8a80977e2ef4c9703a3d902": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=e6ry3Jfj4Hvi1m%2FKWNq%2BO4dxba0%3D&Expires=1423168609&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "c4a884efe935ed4106e0940b5146c9f5": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=CSMObc9kd7n9bt2DKCmNFVZUVh0%3D&Expires=1423168611&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "260c00ee41cd6757d7fd3cb24ab35c95": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=rGgrHfE5wYLQ6UF9tSLU0iOMoFI%3D&Expires=1423168612&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "fd04b49a11693b58de97413222518884": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=iyRHd%2FfVB7iJ3YU8FAzPLDtEV1Q%3D&Expires=1423168614&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "09becb15ab00918cd4402d7581c3c11d": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=5KyRoAviogYwkpFmqnHmtK1aqAg%3D&Expires=1423168615&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "e7b5d27ca26b86526e654220defd9b28": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=Q7XOq5ChzA60LA4ydKYMA7CHTwI%3D&Expires=1423168616&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "511f92865b5171e902e1d04986c67cb0": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=JgOQfj%2BLyawLvZVqveCymC%2ByORk%3D&Expires=1423168617&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "5d118d6f90a1ea2c661781b669cf1a16": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=g61Fc23N0RBzjTyQPNqPcSUrWy0%3D&Expires=1423168618&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "e140d9a0057425027e019e6f4ca3f43c": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=BowHmQ4LIcm1iYiKKO8E02H2WxI%3D&Expires=1423168619&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "a059e03cab39a6361e2831feb51df65c": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=bPiK%2F1nbnd2BnSqp8USqvCN3%2Buk%3D&Expires=1423168621&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "421ee8a8058b99d6b9eff601cae85e27": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=cF8%2FGp2g6cMJGnI3VQnx4Z%2FGrD4%3D&Expires=1423168622&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />", 
  "91f1200dfb4dc479231f11c6d442c21f": "<link rel=\"stylesheet\" href=\"https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=TC172ydCorbEYuK9BPAuN%2B%2BBKJI%3D&Expires=1423168623&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA\" type=\"text/css\" media=\"all\" />"
}

在css文件夹中,有56个.css文件,所有文件都包含相同的内容,其中包含了应有的内容。

当我尝试加载页面时,我遇到了500错误,并且在日志中:

OfflineGenerationError: You have offline compression enabled but key "82eb0d398802e74ae1d897a61e1c5b9b" is missing from offline manifest. You may need to run "python manage.py compress".

我不明白的第一件事是它为什么会生成56个不同的.css文件,内容完全相同,这是正常的吗?

我一直在阅读很多关于此的问题,但我还没有找到任何解决方案。有人可以帮忙吗?

感谢。

1 个答案:

答案 0 :(得分:0)

在我敲了三天之后(我必须在此之前修复压缩机的其他问题),我发现了问题。这是S3中生成的.css文件的URL:

https://staging-ekiphos-statics.s3.amazonaws.com/static/CACHE/css/048c299ffb55.css?Signature=pVKMqQHS%2BiZ9SIIgu2c1o1dhvpA%3D&Expires=1423168574&AWSAccessKeyId=AKIAI7KZTNYNOMIHBWKA

这个网址无法访问,这就是它生成56个不同的.css文件的原因。通过添加以下行,我阻止了S3 boto在url中添加签名和expirity信息:

AWS_QUERYSTRING_AUTH = False

执行此操作时,manifest.json只包含一个条目,并且只创建一个可访问的.css文件。