Thanks for your quick reply. Yes, this is also what I found, so I was quite
shure that my code will never work. What I try to do is to render a list of
database objects. But not only on one page but on different pages and with
slightly different designs in each of the lists. So my plan was, to avoid
writing individual templates for each list, to create one base template for
the general appearance of such list items and only adapt blocks on each
individual list.

Explained the other way around, how would I render a template.html which
needs a database object  in a for loop and which extends a base_template
html?

Hope I achieved to explain the problem well enough...

2015-10-28 16:39 GMT+01:00 Tim Graham <timogra...@gmail.com>:

> I think that's a limitation described in the {% include %} docs:
> https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#include.
> See the "Note" box where it says:
>
> The include
> <https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#std:templatetag-include>
> tag should be considered as an implementation of “render this subtemplate
> and include the HTML”, not as “parse this subtemplate and include its
> contents as if it were part of the parent”. This means that there is no
> shared state between included templates – each include is a completely
> independent rendering process.
>
> Blocks are evaluated *before* they are included. This means that a
> template that includes blocks from another will contain blocks that have 
> *already
> been evaluated and rendered* - not blocks that can be overridden by, for
> example, an extending template.
> ----
> It's difficult for me to make a suggestion about how to structure things
> without a more complete understanding of what you're trying to do.
>
> On Wednesday, October 28, 2015 at 11:28:07 AM UTC-4, svewa wrote:
>>
>> Hi all,
>>
>> sorry if it might be a stupid question for pro's but it seems I still
>> miss a deeper knowledge of some design aspects. What I try to do is the
>> following:
>>
>> <ul>
>> {% for obj in objects %}
>>         <li>
>>             {% include 'item.html' with object=obj %}
>>         </li>
>> {% endfor %}
>> </ul>
>>
>>
>> this I need to to in three different apps with slightly varying
>> appearance of item.html.
>>
>> So my idea was to create a root_item.html in my root template folder and
>> simply do in item.html the following::
>>
>> {% extends "root_item.html" %}
>> {% block anyblock %}
>> {% endblock %}
>>
>>
>> I'am so far that I guess I know that this will not work. Could anyone
>> explain to me the prefered way to achieve this? In words, I need a base
>> template which extensions should be rendered as list items...
>>
>> Sorry I'am shure it is easy but I am stuck
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/SFh41AI0dcM/unsubscribe.
> To unsubscribe from this group and all its topics, 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/af32f8fd-e83b-4767-8f37-eaccc1ec70b8%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/af32f8fd-e83b-4767-8f37-eaccc1ec70b8%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/CAH4Xs%2BO%2Bk20ht4Lhiw9eA6jNcs-yC8qEj9MzGCUpvKbjEFFnOw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to