The browser/client does not get two 'chunks' of HTML, Django renders the
entire page first and sends the entire rendered piece at once after
rendering both templates.

If you need your JS to be interpreted earlier, add an extra {% block %} to
template_A up in the <head> section, and override that block rather than
(or in addition to) overriding your content block so that your JS is
interpreted before the rest of the body.

-James
On Jul 11, 2015 5:02 PM, "Nkansah Rexford" <[email protected]> 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 [email protected].
> To post to this group, send email to [email protected].
> 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 [email protected].
To post to this group, send email to [email protected].
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/CA%2Be%2BciUH4i%3DN0Yg%2B6OgkNFWSbw6sqqwB8B_x-xCwcNrPwbNx9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to