Skip to content

Commit

Permalink
Merge pull request #5 from return1/django_admin_prefix_issue
Browse files Browse the repository at this point in the history
fix the broken javascript admin resources with S3Boto on Django 1.4
  • Loading branch information
jamstooks committed Sep 19, 2013
2 parents 280cb22 + 7c7cdf2 commit 153cf2a
Showing 1 changed file with 13 additions and 2 deletions.
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

0 comments on commit 153cf2a

Please sign in to comment.