Hi,

I have the following situation:

I have a dictionary with dictionaries nested, like so:

cutsites = {'rfc10': {'EcoRI':[20, 112], 'XbaI':[5, 12, 45], 'SpeI':
[45, 129, 245]},
                  'rfc21': {'EcoRI':[2, 22], 'XbaI':[15, 42, 66],
'SpeI':[55, 69, 95]}
                  }

And I also have the following dictionary:

rs_sites = {'EcoRI': 'GAATTC',
            'XbaI': 'TCTAGA',
            'SpeI': 'ACTAGT'
            }

Now in my template I run through the cutsites dictionary and present
the content as so:
{% for renz,csites in cutsites.rfc21.items %}
    {{ renz }} (Site: {{ rs_sites.{{ renz }} }}):
        {% if not csites %}
            NA
        {% else %}
            {% for sites in csites %}
                <span class="bad">{{ sites }}, </span>
            {% endfor %}
        {% endif %}
        ;&nbsp;
{% endfor %}

I need to call the rs_sites value based on the renz variable and was
hoping I could stick a variable within a variable like so:
{{ rs_sites.{{ renz }} }}

I've tried using {% ifequal %} with the keys and values within the for
but without success as shows below (I know, what a mess!):

{% for renz,csites in cutsites.rfc21.items %}
    {{ renz }}
    {% for enz, string in rs_sites.items %}
        {% ifequal enz renz %}
           {{ string }}
        {% endifequal %}
    {% endfor %}
        {% if not csites %}
            NA
        {% else %}
            {% for sites in csites %}
                <span class="bad">{{ sites }}, </span>
            {% endfor %}
        {% endif %}
        ;&nbsp;
{% endfor %}


I can see that I'm using too much logic in my template but was hoping
it would be possible without having to go into making custom tags.

Thanks in advance for any help provided.

Kind regards,
Ricardo

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