3

Okay, I've been learning Django but am a beginner with the framework. I'm a fan. I have a build running on heroku with the static files being served from Amazon S3 using Django-storages. It was very easy to get up and running with no difficulties.

However, I'm missing the calendar icons. Checking the source shows there's no trailing slash between admin & img.

Example:

https://s3.amazonaws.com/heroku-sdbhvaehv/adminimg/icon_clock.gif

Its a bug apparently in Django-storages listed here:

http://code.larlet.fr/django-storages/issue/121/s3boto-admin-prefix-issue-with-django-14

And I've implemented the various fixes that are listed in the comments with no luck.

I've found two posts around on SO and Google Groups but there is no solutions.

Using Django and s3boto, some admin images (icon_clock.gif & icon_calendar.gif) don't display

So -- I'm looking for any solutions on how to get this icon fixed. I don't care if I have to modify something after every push, or do whatever - but I can't have a missing calendar icon.

Any help out there?

4
  • 1
    This hack is probably a complete non-starter but can you inject a little jquery into the pages? Iterate over all img elements, test their src attribute and fix as necessary? Related: stackoverflow.com/questions/554273/… Commented Jul 31, 2013 at 2:38
  • In a pinch, that was something I was thinking about. Commented Aug 1, 2013 at 15:29
  • 1
    Or even more hacky (yuk) store a copy of icon_clock.gif at s3.amazonaws.com/heroku-sdbhvaehv/adminimg? Commented Aug 1, 2013 at 17:48
  • It may be yuk, but I'm trying to get a fix - not solve the world's problems. Putting an image there with a readme.txt is fine with me. Thanks for the suggestion. I'm a bit embarrassed I didn't think of it while I was working on this thread. Commented Aug 5, 2013 at 14:00

1 Answer 1

4

The problem is not with boto, or with django-storages.

The problem is that the django admin is missusing the {% static %} tag. The static tag assumes (rightly) that it is viewing the entire url, and that it can modify that url arbitarily. By passing in only a prefix, the django admin is breaking that contract (which will not be detected in the simplest cases, but will be a big problem when you try to do anything more complex.

You should file a bug or patch against django to explicitly pass all asset urls, in full, to the static tag, and dump these full resource URIs into the javascript context.

EDIT: This solution should work for you: http://code.larlet.fr/django-storages/issue/121/s3boto-admin-prefix-issue-with-django-14#comment-1604389

Just make sure you have AWS_QUERYSTRING_AUTH set to False, or you will get querystrings sandwiched in there.

Sign up to request clarification or add additional context in comments.

4 Comments

+1 for the comment. Is there a suggested fix that I can do in the meantime?
Thank you. I've tried both of those solutions with no fix. I'll review them again today and see what I did wrong.
what output do you get when you use both of these together?
It's fixed in the current development version. See stackoverflow.com/a/18698270/284318

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.