I recently installed Django Compressor (1.2) on my Django app (1.4.1). Up until I installed django-compressor, when I ran collectstatic, it would upload my static files to S3 via boto flawlessly without copying them anywhere else locally. However, when I installed django compressor, running collectstatic either:
A) Uploads my static files to S3, but replaces all the local versions with empty files.
B) Uploads my static files to S3, but copies the local versions to my root folder.
For result A, I have
COMPRESS_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'proj/static',)
For result B, I have
STATIC_ROOT = ''
COMPRESS_ROOT = STATIC_ROOT
I understand why B is copying the files to root, since that's what the STATIC_ROOT is set to, but if I comment out COMPRESS_ROOT, collectstatic goes back to normal (aka not modifying anything locally and just uploading to S3). I would have thought that COMPRESS_ROOT wouldn't have any effect on collectstatic since STATIC_ROOT is staying the same regardless. Apparently that's not the case.
As a workaround, I've been doing the following:
When I want to run python manage.py compress, I set COMPRESS_ROOT as the following:
COMPRESS_ROOT = os.path.join(os.path.abspath(os.path.dirname(file)), 'proj/static',)
- When I want to run python manage.py collectstatic, I comment out COMPRESS_ROOT which returns collectstatic to it's pre-django-compressor functionality.
Clearly this is a hack and I'd like to figure out how to get them to play nice. Any suggestions would be greatly appreciated.
Relevant code below: #settings.py
STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(os.path.abspath(os.path.dirname(__file__)),'proj/static',),
)
AWS_STORAGE_BUCKET_NAME = #bucket-name
S3_URL = 'https://%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
STATIC_DIRECTORY = '/static/'
STATIC_URL = S3_URL + STATIC_DIRECTORY
COMPRESS_ENABLED = True
COMPRESS_OFFLINE = True
COMPRESS_URL = STATIC_URL
#COMPRESS_ROOT = STATIC_ROOT
#COMPRESS_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'proj/static',)
COMPRESS_STORAGE = 'travel.proj.services.storage.CachedS3BotoStorage'
STATICFILES_STORAGE = 'travel.proj.services.storage.CachedS3BotoStorage'
AWS_LOCATION = 'static'
COMPRESS_JS_FILTERS = [
'compressor.filters.template.TemplateFilter',
]