I feel like I've tried just about everything here in getting static and user uploads folders to work with s3. At this point when I run collectstatic
all the folders inside media
end up inside static
, even though I'm pretty sure I configured things for two folders to be created.
I suspect it's something to do with django-filebrowser. It seems that they have made some settings for storages but for the life of me I can't figure out how to make them work:
http://django-filebrowser.readthedocs.org/en/latest/settings.html?highlight=storages
http://django-filebrowser.readthedocs.org/en/latest/admin.html?highlight=storages
Has anybody here gotten django-filebrowser to actually work with s3? If not where else do you recommend I host user upload files?
django-filebrowser it tied pretty close to my app. I have it setup to automatically create an array of thumbnails with each image upload and it works great. Its useless to me if I can't get it off my local machine though.
excerpts from my settings.py
:
from django.conf import settings
import dj_database_url # HEROKU
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
INSTALLED_APPS = (
'grappelli',
'filebrowser',
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.admin',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'debug_toolbar',
'frontpage',
# adding south to try out with django 1.6
'south',
'inplaceeditform',
'inplaceeditform_extra_fields',
'storages',
'boto',
)
# GRAPPELLI SPECIFIC RECOMMENDED ##
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.FileSystemFinder',
)
#-------------------------------------------------------------
# DJANGO STORAGES
DEFAULT_FILE_STORAGE = 'addition_interiors_project.s3utils.MediaRootS3BotoStorage'
STATICFILES_STORAGE = 'addition_interiors_project.s3utils.StaticRootS3BotoStorage'
AWS_ACCESS_KEY_ID = 'xxxxxxxxxx'
AWS_SECRET_ACCESS_KEY = 'xxxxxxxxxx'
AWS_STORAGE_BUCKET_NAME = 'xxxxxxxxxx'
AWS_PRELOAD_METADATA = True
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
os.path.join(BASE_DIR, 'media'),
)
MEDIA_ROOT = '/media/'
STATIC_ROOT = '/static/'
S3_URL = 'http://s3.amazonaws.com/%s' % AWS_STORAGE_BUCKET_NAME
STATIC_URL = S3_URL + STATIC_ROOT
MEDIA_URL = S3_URL + MEDIA_ROOT
#-------------------------------------------------------------
#-------------------------------------------------------------
# DJANGO-FILEBROWSER
#-------------------------------------------------------------
FILEBROWSER_VERSIONS_BASEDIR = '_versions'
FILEBROWSER_VERSIONS = {
'admin_thumbnail': {'verbose_name': 'Admin Thumbnail', 'width': 60, 'height': 60, 'opts': 'crop'},
'thumbnail': {'verbose_name': 'Thumbnail (1 col)', 'width': 60, 'height': 60, 'opts': 'crop'},
'small': {'verbose_name': 'Small (2 col)', 'width': 140, 'height': '', 'opts': ''},
'medium': {'verbose_name': 'Medium (4col )', 'width': 300, 'height': '', 'opts': ''},
'big': {'verbose_name': 'Big (6 col)', 'width': 460, 'height': '', 'opts': ''},
'large': {'verbose_name': 'Large (8 col)', 'width': 680, 'height': '', 'opts': ''},
'mega': {'verbose_name': 'Mega (12 col)', 'width': 940, 'height': '', 'opts': ''},
}
FILEBROWSER_ADMIN_VERSIONS = getattr(
settings, 'FILEBROWSER_ADMIN_VERSIONS', ['thumbnail', 'small', 'medium', 'big', 'large', 'mega'])
also my s3utils.py:
from storages.backends.s3boto import S3BotoStorage
StaticRootS3BotoStorage = lambda: S3BotoStorage(location='static')
MediaRootS3BotoStorage = lambda: S3BotoStorage(location='media')
my folder structure:
addition_interiors_project
..manage.py
..addition_interiors_project
....addition_interiors_project
....media
....static
....frontpage
....s3utils.py
....settings.py
....urls.py
....wsgi.py