I think the issue here is in how you're loading jQuery. It doesn't seem like jQuery has been loaded successfully. Make sure the path to your jQuery file is correct. This seems more like a client side issue rather than a server side (Django) issue.
When Django sends the HTML response to your browser, it's already in its final form. Meaning both templates A and B has already been rendered and assembled together. All this is done on the server side. The loading and execution of JS files happens on the client side (browser). Since Django is a server side framework, it isn't concerned about how JS files are loaded on the browser. On Jul 12, 2015 08:02, "Nkansah Rexford" <seanmav...@gmail.com> wrote: > If template B extends template A, template B renders/parses its content > independently before being added to the parent A template. > > Is there a way to make template B *wait* and render only *after* when > added to the parent A template? > > Independent rendering of extended pages ( same thing happens with the {% > include %} > <https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#include> > tag too [ see the Note section there] ) sounds great if thats what one > expects. > > In my case, I wish I could let B (along with any includes made) *wait* , > conjoin with the parent template, A, then all in unison, renders/parses the > content together. I tried to do below, but it failed, for obvious reasons ( > $ function isn't defined. Template_B doesn't reference jquery resource ) > > template_B.html: > > {% extends 'template_A.html' %} > {# usual html stuffs #} > > {% block content %} > {# page content stuffs here #} > <script type="text/javascript"> > // A function targeting a specific area of, only > // and Only the template_B.html page, e.g > $( ".class" ).addClass( "new-class" ); > </script> > {% endblock %} > > What I want to have is: > > template_A.html > > <html> > <head><!-- Head things --> > <script src="jquery-resource"></script> > </head> > <body> > <!-- below snippet coming from template_B.html --> > {% block content %} > {# page content stuffs here #} > <script type="text/javascript"> > // A function targeting a specific area of, only > // and Only the template_B.html page, e.g > $( ".class" ).addClass( "new-class" ); > </script> > {% endblock %} > </body> > </html> > > Then when everything of template B has arrived, django *now* renders the > page, in which case, > > Is such approach a bad thing? Performance-wise? Perhaps security-wise? > Please enlighten me. Such a feature wouldn't be default, but a switch in > cases like my own, one can turn on. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/c4106146-0892-4513-bab5-f6c7d18c64a3%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/c4106146-0892-4513-bab5-f6c7d18c64a3%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMHY-Kdhoc0J8dFu4caVbgU3jQPfipFOcB3BwVD_Mxa2s-ZEBQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.