Q:

'tuple' object has no attribute 'has_header'

This is my code in my template file 
{% load section_settings %} ## Loading a template tags
{% section_settings declaration.id user.id as the_section_setting %}

Now the value of :
the_section_setting = {'A': {'included': True, 'editable': True, 'alwaysIncluded': False, 'complete':False}, 'C': {'included': False, 'editable': True, 'alwaysIncluded': False, 'complete': False}}

Now in my template file when I tried to run this code in an js script:
<script type="text/javascript">

function initTree(showline){    
    {% for section in the_section_setting %}    
    alert("{{ the_section_setting[section]['included'] }}")
    {% endfor %}
        }   
</script>

This throws error 'tuple' object has no attribute 'has_header' . Basically I have tested the same in python shell , it is working fine for me. But not in the template. What is mistake I am doing. I wanted the value of included key for each element in the dict.
Thanks in Advance .
I am getting the following error:
AttributeError at /declaration/2991/detail

'tuple' object has no attribute 'has_header'

Request Method:     GET
Request URL:    http://10.6.208.12:8000/declaration/2991/detail
Django Version:     1.4
Exception Type:     AttributeError
Exception Value:    

'tuple' object has no attribute 'has_header'

Exception Location:     /usr/local/lib/python2.6/dist-packages/django/utils/cache.py in patch_vary_headers, line 140
Python Executable:  /usr/bin/python
Python Version:     2.6.6

A:

The correct syntax would be
<script type="text/javascript">

function initTree(showline)
        {    
           {% for section, secval in the_section_setting.iteritems %}
           alert("{{secval.included}}")
           {% endfor %}
        }   
</script>

To be more verbose, I would go for something like
<script type="text/javascript">

function initTree(showline)
        {    
           {% for section, secval in the_section_setting.iteritems %}
               {% if secval.include %}
                   alert("The {{ section }} is included.")
               {% else %}
                   alert(""The {{ section }} is not included.")
               {% endif %}
           {% endfor %}
        }   
</script>

Help docs - https://docs.djangoproject.com/en/1.4/topics/templates/

