I'm trying to do something with a template that I thought would be very
simple but I've not yet found a way to make it work at all.
from django.template import Template, Context
fields = ("f1", "f3")
data = [
{"f1": "Foo", "f2": "Skip ","f3": "Bar"},
{"f1": "Cat", "f2": "Ignore","f3": "Dog"},
{"f1": "Him", "f2": "Avoid ","f3": "Her"},
]
t = Template("""
{% for row in data %}
{% for f in fields %}
{{ row.f }}
{% endfor %}
{% endfor %}
""")
print t.render(Context({'fields': fields, 'data': data}))
I want to print out the data items row-by-row but skipping 'f2' since
it's not listed in 'fields'. The above is how it seems like it ought to
work, but it just ignores me. Lots of other crazy permutations didn't
work either.
Can someone show me what (very simple) thing I'm missing?
Thanks,
Michael
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---