On 11 Aug 2006, at 20:05, Michal wrote:
>
> Hello,
> I was trying to include some of the menu templates according to
> flatpage.url variable (I have several local menu templates):
>
> {% include flatpage.url|menu %}
>
> But this doesn't work. It seems to me, that flatpage.url|menu isn't
> evaluated, because find_template_source from django/template/loader.py
> wasn't call (I put there print name, and for menu include it doesn't
> print anything; for some other includes with hardcoded template  
> name print).
>
>
> Could anybody tell me, if my approach is bad or not, please.

Hi Michael,

As far as I can recall, include will only include statically named  
files eg. {% include 'somesection.html' %}.

A different approach may be to extend the template you're working in  
(say your include is in base.html) and then extend that with the  
template you're trying to include, then rather than rendering to the  
base template and including the section, render to the sub-page...  
It's easier with an example.

You have: ----------------------------------------
base.html:
...
{% include something %}
...

and in your view:
render_to_response('base.html', {'something': ...})

Try changing this to: ----------------------------------------
base.html:
{% block extra %}{% endblock %}

something.html:
{% extends 'base.html' %}
{% block extra %}Howdy, world!{% endblock %}

and in you view:
render_to_response('something.html', {})
----------------------------------------

Good luck, John.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to