Skip to content

Instantly share code, notes, and snippets.

@CapnKernel
Created December 10, 2013 06:10
Show Gist options
  • Select an option

  • Save CapnKernel/7886376 to your computer and use it in GitHub Desktop.

Select an option

Save CapnKernel/7886376 to your computer and use it in GitHub Desktop.
from django.shortcuts import render
from django.template import Template, RequestContext
from django.http import HttpResponse
def view(request):
nds = {
u'outer1': ('mid1a', 'mid1b'),
u'outer2': ('mid2a', ),
}
ts = u"""<pre>
nds={{ nds }}.
{% for outerk, outerv in nds.items %}
outerk={{ outerk }} outerv={{ outerv }}
{% for mid in outerv %}
mid={{ mid }}
{% endfor %}
{% endfor %}
</pre>
"""
nds = {
u'outer1': ('mid1a', 'mid1b'),
u'outer2': ('mid2a', ),
}
t = Template(ts)
d = {'nds': nds}
c = RequestContext(request, d)
s = t.render(c)
print "s=", s
return HttpResponse(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment