Ok, I'm wondering if there is any way to do this. Let me give a couple of ***simplified*** examples to clarify what I'm talking about here. I make "simplified" previously apparent because what I'm actually trying to do is much more complicated than these examples.
View code: ====================== return render_to_response('/path/to/html' , { 'foo': {'bar': 'eggs'} , 'spam': 'bar' , }) ====================== Now, in my template I want to access {{ foo.bar }} via the dereferenced *value* of "spam". Essentially, though I know this doesn't work, it would look like this: Template code: ====================== Output "eggs": {{ foo.{{ spam }} }} ====================== Is there any way at all to do something like that? Here is another example, though I already know a workaround for it (at the bottom), it seems like there should be a better way. View code: ====================== list1 = ['one' , 'two' , 'three'] list2 = [1 , 2 , 3] return render_to_response('/path/to/html' , { 'list1': list1 , 'list2': list2 , }) ====================== In the template, while looping through "list1", I want to be able to directly access by index the corresponding value in "list2". I know the following doesn't work, but again, it seems like there should be a way to do this. Note that this is a greatly simplified version of what I'm actually trying to accomplish!! Template code: ====================== {% for item in list1 %} <p>{{ item }}: {{ list2.{{ forloop.counter0 }} }}</p> {% endfor %} ====================== Now, I know I can accomplish the above with a highly inefficient nested loop: Template code: ====================== {% for item in list1 %} <p>{{ item }}: {% for item2 in list2 %} {% ifequal forloop.counter0 forloop.parentloop.counter0 %} {{ item2 }} {% endifequal %} {% endfor %} {% endfor %} ====================== Essentially, is there any way of performing a nested dereference operation like these? Jay -- Jay Deiman \033:wq! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---