I'd like my javascripts to know MEDIA_URL so they can pull pictures
from there (for a slideshow) and I was wondering the best way of doing
this.

I figure the best way would be to create one javascript file that goes
through the Django templating and makes a variable available for the
other scripts. Something like:

//site.js
var site = {
  medai_url = '{{ MEDIA_URL }}'
};

Then other scripts could access it through site.media_url. My question
is how best to templatize a javascript file. I could just put it in my
base.html file between <script></script>, but that way's kind of poo.

If I were to templatize the entire file, it would have to go through
urls.py, but for consistency's sake I'd like the url to be within my
media/javascript folder, ie a urls.py entry something like:

urlpatterns = patterns('',
  (r'^' + settings.MEDIA_URL + r'javascript/site.js$', media_js),
)

But then I run into the problem that MEDIA_URL is an absolute URL, so
I'd probably have to do some string manipulation to get the relative
URL out.

Am I missing an easier way of doing it? Thoughts on these approaches?
Thanks.
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to