python - Django static file URLS are broken -


i using boto2 s3 integration django-admin app on heroku. of urls being generated incorrectly static files. example:

https://bucket.s3.amazonaws.com/folder/static/admin?signature=xxx&expires=yyy&awsaccesskeyid=zzzimg/icon_calendar.gif

when should

https://bucket.s3.amazonaws.com/folder/static/admin/img/icon_calendar.gif?signature=xxx&expires=yyy&awsaccesskeyid=zzz

notice img/icon_calendar.gif out of place. thing can think causing issue code used make static files on sub folder in bucket. based on this solution

#s3utils.py storages.backends.s3boto import s3botostorage import  os  static_root = 'folder/static' media_root = 'folder/media'  staticroots3botostorage = lambda: s3botostorage(location=static_root) mediaroots3botostorage  = lambda: s3botostorage(location=media_root)  #settings.py ... aws_storage_bucket_name = "bucket" aws_access_key_id = 'zzz' aws_secret_access_key = 'aaaa' default_file_storage = 'app.s3utils.mediaroots3botostorage' staticfiles_storage = 'app.s3utils.staticroots3botostorage'  s3_url = 'http://%s.s3.amazonaws.com/' % (aws_storage_bucket_name)  static_root = '/folder/static/' media_root = '/folder/media/'  static_url = '%sfolder/static/' % (s3_url) media_url = '%sfolder/media/' % (s3_url) 

what causing urls corrupted?

i found fix in git repo. s3utils.py file looks like

#s3utils.py storages.backends.s3boto import s3botostorage import  os  static_root = 'folder/static' media_root = 'folder/media'  class fixeds3botostorage(s3botostorage):     def url(self, name):         url = super(fixeds3botostorage, self).url(name)         if name.endswith('/') , not url.endswith('/'):             url += '/'         return url  staticroots3botostorage = lambda: fixeds3botostorage(location=static_root) mediaroots3botostorage  = lambda: fixeds3botostorage(location=media_root) 

Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -