Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the broken javascript admin resources with S3Boto on Django 1.4 #5

Merged
merged 1 commit into from
Sep 19, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions s3_folder_storage/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@
from storages.backends.s3boto import S3BotoStorage
from django.conf import settings

class StaticStorage(S3BotoStorage):
class FixedS3BotoStorage(S3BotoStorage):
"""
fix the broken javascript admin resources with S3Boto on Django 1.4
for more info see http://code.larlet.fr/django-storages/issue/121/s3boto-admin-prefix-issue-with-django-14
"""
def url(self, name):
url = super(FixedS3BotoStorage, self).url(name)
if name.endswith('/') and not url.endswith('/'):
url += '/'
return url

class StaticStorage(FixedS3BotoStorage):
"""
Storage for static files.
The folder is defined in settings.STATIC_S3_PATH
Expand All @@ -15,7 +26,7 @@ def __init__(self, *args, **kwargs):
kwargs['location'] = settings.STATIC_S3_PATH
super(StaticStorage, self).__init__(*args, **kwargs)

class DefaultStorage(S3BotoStorage):
class DefaultStorage(FixedS3BotoStorage):
"""
Storage for uploaded media files.
The folder is defined in settings.DEFAULT_S3_PATH
Expand Down