On 9 November 2010 11:25, samuele.mattiuzzo <samum...@gmail.com> wrote:
> Hi all,
> i have a problem with a django template.
>
> i have a value (a number) stored into a mysql database and i'm
> accessing it using {{ totem.layout.communitySpace }}
>
> This number sould be used to get a page:
> {% include "bacheche/clip_{{ totem.layout.communitySpace }}.html" %}
>
> and it should return "clip_2.html" (for example).
>
> This doesn't seem possible, since i receive "Page
> clip_{{ totem.layout.communitySpace }}.html not found"
> I also tried without using parenthesis, but i get the same error
> ("Page clip_totem.layout.communitySpace.html not found") and i have to
> use the "ifequal" tag to include the correct page, but this isn't
> dynamic at all, everytime we add a new page, we also have to edit the
> main template if - else's statements!
>
> How can i manage this? Thank you all for your suggestions!
>

You should first create the name as a string and then pass it to the
{% include %}. You can do this in view (with a simple "clip_%d.html" %
num), a custom tag or with something horrible like this:

{% with totem.layout.communitySpace|stringformat:"d" as page_number %}
    {% with "bacheche/clip_"|add:page_number|add:".html" as template_name %}
        {% include template_name %}
    {% endwith %}
{% endwith %}


-- 
Łukasz Rekucki

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