It sounds like you're passing the variable in your context, but {{x}} doesn't get converted to {{some_value}} in the script text. This may be because you're html-including the script in your page without passing it through urls.py first. Here's what I do: 1) the scripts that need to get context-parsed live in the templates/ js directory, rather than the usual static/js. 2) they are declared in urls.py: (r'^myproject/rollover/$', 'rollover' ), # corresponds to rollover.js
and there is a view function for each one: def rollover(request): """ Loads the rollover script. """ return render_to_response('js/rollover.js', {myvar':myvar}) 3) they are included in html accordingly: <script type="text/javascript" src="{{TEMPLATE_DATA_URL}}js/ some_normal_script.js"></script> <script type="text/javascript" src="{{APP_URL}}rollover/"></script> Mae On Feb 6, 7:17 pm, "damacy" <[EMAIL PROTECTED]> wrote: > hi, there. > > i'm a writing a template with a section of javascript code in it. i > need to use django variables in the script and just wondering how i > can do it. > > i tried > <script> > {{ variable_x }} > </script> > > but it does not seem to work. > > has anyone any clue? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---