I'm getting a little stuck on a Django problem where I can't access the values of a dict in a for loop. It works outside the for loop, just not inside.
Am I missing the obvious here?
Python:
err{}
err['else'] = {'class': 'Low', 'txt': 'zero'}
err['if'] = {'class': 'High', 'txt': 'one'}
data = { 'errors': err }
return render(request, 'index/error.html', data)
HTML template:
<p>{{ errors }}</p>
<p>{{ errors.if }}</p>
<p>{{ errors.if.class }}</p>
{% for error in errors %}
<div class="{{ error.class }}"><p>{{ error.txt }}</p></div>
{% endfor %}
The upper 3 lines are for code debugging and work just fine. The for loop doesn't produce any code.
Best regards, LVX