Dow,
I am using the chained approach which you suggested ( base -> topbar ->
sidebar -> view1 ). It works perfectly as i wanted :)

Thanks!


On Sun, May 19, 2013 at 10:50 PM, Dow Street <dowstr...@prodigy.net> wrote:

> Hi.  I'm not sure, but we may be using the terms 'parent' and 'child'
> differently (i.e. what you're calling a child I'm calling a parent?).  I
> have only used django template inheritance where a given template file has
> at most one {% extends %} tag in it - that is what I am referring to when I
> say 'has at most one parent'.  However, the base.html template (the parent)
> is extended by many different child templates (e.g. view1.html).  Is this
> what you are thinking as well?
>
> If you want a template to inherit from multiple parents - e.g. include
> multiple {% extends %} tags - well, that is not something I have done
> previously (and I can't say whether that model is supported).  However, you
> can achieve comparable functionality (I think) by adding a layer in the
> inheritance hierarchy - for example:
>
> base.html - has empty blocks for topbar and sidebar
> topbar.html - extends base.html and contains the code for the topbar
> sidebar.html - extends topbar.html and contains the code for the sidebar
> view1.html - extends sidebar.html and contains the code specific to that
> page
>
> If you load the view1.html template in your view function all those {%
> extends %} tags will cause the django template engine to walk the
> hierarchy, starting from base -> topbar -> sidebar -> view1, leaving you
> with a single 'merged' html file.  At each step, if a child template has a
> block with the same name as one of the parents, the child block will
> overwrite the contents of the parent block.  Does this make sense?
>
> (and I should note that I am by no means an expert in the django template
> processor - this is just my understanding).
>
> R,
> Dow
>
>
> On May 18, 2013, at 11:12 PM, Parin Porecha <parinpore...@gmail.com>
> wrote:
>
> > Dow,
> > I am trying to have multiple children of the same parent. And thats why
> I'm not able to decide which child to load. Anyways, the sidebar and topbar
> are more or less static, so I guess there isn't much need to have separate
> files for them. I want to have them different so that developing that
> section of the website would be easier. In the end, I want to merge all
> those different sections into one file and load that in my view. Can you
> please help me with this ?
> >
> > Artem,
> > Yes, I get it :) Thanks!
> >
> >
> > On Sat, May 18, 2013 at 9:56 PM, Artem Zinoviev <arzinov...@gmail.com>
> wrote:
> > if you have base.html and sidebar.html, base.html file just declare {%
> block sidebar %} section and sidebar.html make implementation of it, if you
> have SidebarView, then you load sidebar.html and this file take all from {%
> extends base.html %}. And if you try load base.html from SidebarView - you
> get it :-), but {% block sidebar %} section be blank...
> >
> > суббота, 18 мая 2013 г., 12:14:37 UTC+3 пользователь Parin Porecha
> написал:
> > Hi,
> >
> > I have just started to learn Django's template inheritance and I am
> stuck due to this problem -
> > In my application's 'base.html', I have defined two blocks -
> > {% block topbar %}{% endblock topbar %}
> > and
> > {% block sidebar %}{% endblock sidebar %}
> >
> > I have 2 templates - 'sidebar.html' which extends {% block sidebar %}
> > and 'topbar.html' which extends {% block topbar %}
> >
> > The 'sidebar.html' is also divided into further blocks which are
> extended by other templates.
> >
> > Now, my question is -
> > in 'views.py', i have a view which is supposed to render the whole
> homepage ( i.e.- including the sidebar, topbar and content ). So, which
> template should I load in the view, so that both sidebar and topbar plus
> the content defined in other templates gets shown ?
> > because 'base.html' contains many children, I'm confused which one to
> load
> >
> > Thanks to mattmc who tried to help me with this in IRC. Sorry, didn't
> get it completely :)
> >
> > --
> > Regards,
> > Parin Porecha
> >
> > say Kifflom! and look forward to 17.09.13 !
> >
> > --
> > 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?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
> >
> >
> >
> > --
> > Regards,
> > Parin Porecha
> >
> > say Kifflom! and look forward to 17.09.13 !
> >
> > --
> > 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?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
Regards,
Parin Porecha

say Kifflom! <http://www.epsilonprogram.com/> and look forward to 17.09.13 !

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to