1

I want to use both django-pipeline and django-storage on heroku for a personal app. Using only django-pipeline works perfectly, using only django-storage works like a charm but I don't manage to get both of them work together :(

When you read docs, you will find this to make both work with collecstatic:

Django-pipeline:

settings.py
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_CSS = {
'app': {
    'source_filenames': (
        'css/*',
    ),
    'output_filename': 'css/min.css',
    'variant': 'datauri',
},
}

Django-Storage

settings.py
STATICFILES_STORAGE = 's3storages.StaticStorage'

s3storages.py
from storages.backends.s3boto import S3BotoStorage
StaticStorage = lambda: S3BotoStorage(
      bucket='app_name', 
      location='assets'
)

So both app needs to set STATICFILE_STORAGE; when i set storage for amazon s3; django-pipeline doesn't create min.css and min.js...

So i found this solution on stack and did the following:

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

class S3PipelineStorage(PipelineMixin, CachedFilesMixin, S3BotoStorage):
pass

# Define bucket and folder for static files.
StaticStorage = lambda: S3BotoStorage(
      bucket='app_name', 
      location='assets'
)

Now, each time I use collectstatic command, static files are send to amazon S3 but django-pipeline min.css and min.js are not sent... There is no trace of them in my STATIC_ROOT directory also....

Do you know how I can use both together?

EDIT 1:

Now in I have this: (I changed s3storage :) )

settings.py
STATICFILES_STORAGE = 's3storages.StaticStorage'

s3storage.py
from staticfiles.storage import CachedFilesMixin
from pipeline.storage import PipelineMixin
from storages.backends.s3boto import S3BotoStorage

class S3PipelineStorage(PipelineMixin, CachedFilesMixin, S3BotoStorage):
pass

# Define bucket and folder for static files.
StaticStorage = lambda: S3PipelineStorage(
      bucket='app_name', 
      location='assets'
)
Community
  • 1
  • 1
Alex Grs
  • 3,231
  • 5
  • 39
  • 58

1 Answers1

1

Setup STATICFILES_STORAGE to : s3storage.S3PipelineStorage.

Use settings.AWS_STORAGE_BUCKET_NAME and settings.AWS_LOCATION to configure S3.

cyberdelia
  • 5,343
  • 1
  • 19
  • 16