I have since then moved my javascript file to a site_media/scripts directory. My project structure looks like this: webservice/ |-- first/ -- site_media/ -- scripts/ -- templates/ -- urlss/
What I have done is: 1) In urls.py I added (r'^site_media/(?P<path>.*)$', 'django.views.static.serve',{'document_root': 'first/site_media/ scripts', 'show_indexes': True}) 2) In my view I have a render_to_response('TopicTree.html', {'site_media':'first/site_media/scripts/'}, context_instance=RequestContext(request)) 3) In my TopicTree.html template I have a <script type="text/ JavaScript" src="{{ site_media }}alert.js"></script> On Mar 17, 6:04 pm, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Mar 17, 9:30 pm, Igor Ganapolsky <eazy...@gmail.com> wrote: > > > Hi, > > I am running a django dev server. I have a template where I'm calling > > a javascript function from a an external .js file (residing in the > > same directory as the template). However, I get the following error: > > "ReferenceError: al is not defined". Nevertheless, when I just open > > this html page without the django dev server, the function al() works > > fine. > > I am puzzled by this. Does anybody have an idea? > > > Thanks > > Why is your javascript file in the same directory as the template? How > have you configured your server to serve static assets? > -- > 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-us...@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.