Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a better way to iterate over tuples in a (Django) template in Google App Engine?
    primarykey
    data
    text
    <p>Basically, what I'm trying to do is to render <code>os.environ</code> in a template in <a href="http://en.wikipedia.org/wiki/YAML" rel="nofollow noreferrer">Google App Engine</a>. I believe the technology is (or is adapted from) the Django template engine version 0.96 (but correct me if I'm wrong).</p> <p>I found <a href="https://stackoverflow.com/questions/271077/django-how-to-do-tuple-unpacking-in-a-template-for-loop">this question</a> suggesting that you could do:</p> <pre><code>{{ for key, value in environ}} </code></pre> <p>But when I try that, I get an error saying:</p> <blockquote> <p>'for' statements with five words should end in 'reversed': for key, value in environ</p> </blockquote> <p>I guess that question was concerning another version of Django?</p> <p>By the way, the value of <code>environ</code> is set to <code>os.environ.items()</code> before rendering the template.</p> <p>Anyway, I came up a key_value_pair class that I could use instead:</p> <pre><code>class key_value_pair: def __init__(self, key, value): self.key = key self.value = value def make_kvp(key, iter): return key_value_pair(key, iter[key]) </code></pre> <p><code>make_kvp</code> is small "factory" method that I later use to set the <code>environ</code> template value like this:</p> <pre><code>map(lambda x : make_kvp(x, os.environ), os.environ) </code></pre> <p>When doing that everything works just fine, but since I'm a totally new to the technologies in play here, I just wanted to make sure that I'm not overseeing some obvious simpler solution.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload