On Oct 5, 10:34 pm, "neri...@gmail.com" <neri...@gmail.com> wrote: > I was interested in finding out how I would go about accessing django > vars in my javascript file i.e., media_url within javascript. Do I > need to use a serializer to achieve this? > > Thanks, > > Jason
Just put a script element in your Django template which defines a global javascript variable for media_url. It probably makes sense to do this in the base template that the others inherit from. <script type="text/javascript> var media_url = {{ MEDIA_URL }} </script> -- DR. --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---