I feel for you...
Getting Django + Mezzanine working on Amazon with S3 is a pain in the ass. 
Truthfully.
I do have it working though after a lot of learning. 

Where do you plan to store your thumbnails? On S3? If you want Thumbnails 
to work on S3 there is some trickery that you need to do. 

As far as getting it working...

First, using django storages + django folder storage will work provided you 
add some tweaks. It took me A LOT of figuring out due to legacy code and 
existing bugs not being patched in other plugins. Particularly boto and 
storages. 

1) Execute on this bug fix (Brad Bode, the most recent poster is me)
https://github.com/boto/boto/issues/1477

2) Execute on this bug fix:
https://bitbucket.org/david/django-storages/issue/181/from-s3-import-callingformat-seems-broke
If you want to use SSL you will need to use 
the ProtocolIndependentOrdinaryCallingFormat instead of 
OrdinaryCallingFormat
You will also need this if using SSL
*https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header*
 

3) Here is my working settings:

#
# AMAZON - AWS
# S3 config
AWS_SECRET_KEY = os.environ['AWS_SECRET_KEY']
AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID']
AWS_SECRET_ACCESS_KEY = AWS_SECRET_KEY
# Enable S3 deployment only if we have the AWS keys
S3_DEPLOYMENT=AWS_ACCESS_KEY_ID is not None
if S3_DEPLOYMENT:
    AWS_BUCKET_NAME = os.environ['AWS_BUCKET_NAME']
    AWS_STORAGE_BUCKET_NAME = os.environ['AWS_BUCKET_NAME']
    AWS_QUERYSTRING_AUTH = False
    AWS_S3_SECURE_URLS = False
    AWS_S3_ENCRYPTION =  False
    from boto.s3.connection import ProtocolIndependentOrdinaryCallingFormat
    AWS_S3_CALLING_FORMAT = ProtocolIndependentOrdinaryCallingFormat()
    AWS_STORAGE_BUCKET_NAME = os.environ['AWS_BUCKET_NAME']

    DEFAULT_FILE_STORAGE = 's3_folder_storage.s3.DefaultStorage'
    DEFAULT_S3_PATH = "media"
    MEDIA_ROOT = ''
    MEDIA_URL = ''

    STATICFILES_STORAGE = 's3_folder_storage.s3.StaticStorage'
    STATIC_S3_PATH = "static"
    STATIC_ROOT = "/%s/" % STATIC_S3_PATH
    STATIC_URL = 'http://s3.amazonaws.com/%s/static/' % 
AWS_STORAGE_BUCKET_NAME
    ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'
else:
    logging.info("S3 disabled")
    pass

I'll try to check back in on this thread. 

On Tuesday, May 20, 2014 2:50:45 PM UTC-7, bob hosk wrote:
>
> Hi
>
> I'm using the demo mezzanine with a settings.py with 
>
>     STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
>     DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
>
>     STATIC_URL = 'https://' + AWS_STORAGE_BUCKET_NAME + '.
> s3.amazonaws.com/'
>     MEDIA_URL = 'https://' + AWS_STORAGE_BUCKET_NAME + '.
> s3.amazonaws.com/media/'
>
> to store my static/media files on amazon s3 via django storages backed. 
> '/media/ is just a dir
> I created on my amazon s3 bucket from the website console.
>
> All works relatively well with Debug = False, except when I login to the 
> admin, create a new blog
> post and try to upload a featured image. My selected fail yields a HTTP 
> Error and in the console I see
>      [20/May/2014 22:37:33] "POST /admin/media-library/upload_file/ 
> HTTP/1.1" 500 6672
>
> If I comment out the four variables above from settings.py and turn on 
> Debug =True (so
> django is back serving my files on the runserver) there is no problem at 
> all, all media is uploaded
> as expected to the local dir.
>
> I believe my amazon aws credentials must be good, has collectstatic has no 
> problem pushing
> all my css/js/imgs to my amazon bucket, and these seem to be being served 
> ok. It appears just to be
> this media upload from the admin failing...
>
> How can I fix?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to