Within an admin field widget that I am developing, I need to access a
static image from my app.
For example, I have a Google map and I would like to access
"crosshair.gif" from the apps' static folder (er, the collectstatic
folder).
Inside the widget's render() function, I have a formatted string that
contains embedded JS, and within that string I have a JS function that
looks like:
function showCrossHair(divId) {
...
div.innerHTML = '<img src="...">';
...
};
Just wondering what the best way to generically access my app's media is?
Currently, my app has static files collected to this location:
Just curious of the best way to handle linking of images within
widgets whilst keeping things modular?
I was thinking that I could import STATIC_URL from settings and then
do something like this:
div.innerHTML = '<img src="%(static)s/app/crosshair.gif">';
... where "%(static)s" is a reference to my STATIC_URL constant.
I don't really like the above solution because "app" is hard-coded
into the path.
Another solution might be to have a constant at the top of the widget
file that contains the path to a crosshair image:
CROSSHAIR_FROM_STATIC = 'app/crosshair.gif'
But that seems kinda funky too.
Am I making any sense here? :D
Any tips would be greatly appreciated.
Thanks!
Cheers,
Micky
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment