rvidal
unread,Sep 16, 2009, 12:18:05 PM9/16/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
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 %}
;
{% 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 %}
;
{% 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