Opened 11 years ago

Closed 11 years ago

#21395 closed Bug (duplicate)

Admin widget JS files currently make <img> paths using admin_static_prefix

Reported by: rclmenezes@… Owned by: nobody
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently, some admin widgets create images dynamically in JS, requiring paths to files like icon-calendar.gif or selector-search.gif. Django currently accomplishes this by giving the template admin_static_prefix. Javascript then appends /img/image_path to the static prefix to create <img> tags.

This is problematic to developers who change STATICFILES_STORAGE to something like s3Boto. Some of these storage solutions require signatures or credentials to be passed as URL params for the files to be loaded.

One solution is to pass file paths for these files as parameters to DateTimeShortcuts.js and SelectFilter.js.

The admin static prefix is given to the admin base template here:
https://github.com/django/django/blob/master/django/contrib/admin/templates/admin/base.html#L9

And the admin media prefix is given to SelectFilter here:
https://github.com/django/django/blob/master/django/contrib/admin/widgets.py#L48

SelectFilter can be given the path to icon-unknown.gif instead of it being generated here:
https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/SelectFilter2.js

And functions like addClock in DateTimeShortcuts.js can be given the path to icon-unknown.gif directly here:
https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js#L118

etc.

Change History (2)

comment:1 by loic84, 11 years ago

Triage Stage: UnreviewedAccepted

I'm not too sure about the proposed solution, but I agree this problem should be addressed -- accepting the ticket on that basis.

comment:2 by Claude Paroz, 11 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #19538

Note: See TracTickets for help on using tickets.
Back to Top