Daishy,

I don't think you can do that with an include tag. You could do it by
defining a "base_with_menu.html" and having it extend "base.html" You
could make a menu block in base and override it in
base_with_menu.html.

Hope that helps,
Alex

On Feb 3, 3:28 am, Daishy <dai...@web.de> wrote:
> Hi,
> Oh, sorry, but i guess it really was a bit wague:
>
> -- base.html --
> <html>
> <head>
> {% block extrahead %}
> <script src=some javascript></script>
> <some css link>
> {% endblock %}
> </head>
> <body>
> {% include "menu.html" %}
> </body>
> </html>
>
> sub_page would look like you wrote and that works fine. But what i
> want now (and i guess isnt possible and im just on the wrong way here
> ^^) is :
>
> -- menu.html --
> {% block extrahead %}
> {{ block.super }}
> <script src="Some JS only needed for the menu"></script>
> <link some css only needed for the menu/>
> {% endblock extrahead %}
> <div id="MyMenu">
>  ...
> </div>
>
> So the content of menu will be inserted at the include-tag and the
> extra js should be inserted into the extrahead-block. I hope thats a
> better example of what i want to do. Again, i wouldnt be suprised if
> thats not the right way, but is there a way to achive such seperation
> of the templates?
>
> On Feb 2, 4:41 pm, Alex Robbins <alexander.j.robb...@gmail.com> wrote:
>
> > Daishy, it would help if you posted the template code you already
> > tried.
>
> > This is basically how you could do what you are describing:
> > base.html
>
> > <html>
> > <head>
> > {% block extrahead %}
> > <script src=some javascript></script>
> > <some css link>
> > {% endblock %}
> > </head>
> > ....
> > </html>
>
> > sub_page.html
> > {% extends "base.html" %}
> > {% block extrahead %}
> > {{block.super}}
> > <script src=page_specific_js>
> > {% endblock %}
>
> > On Feb 1, 11:56 am, Daishy <dai...@web.de> wrote:
>
> > > Hi,
>
> > > i'm pretty new to django and just stumbled upon a question i didnt
> > > found a solution to, despite the good docs :).
> > > I have a base-template which defines a block calles js and css. Now i
> > > can extend that template and use these blocks andblock.super, to add
> > > javascript or css-files to those already defined in the base-template.
> > > But what if i have a template that is included in the base-template
> > > and should also add js/css-files? I tried defining those blocks within
> > > the included file and callblock.super, but that doesnt seem to work.
> > > Is there anything i missed or another, better solution?
>
> > > (I want to include a menu within the base-template and put all the
> > > html and css/js-script required for it into one file, so its not
> > > scattered on several files)
>
> > > Greetings,
> > > Daishy

-- 
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.

Reply via email to