views:

73

answers:

2

Hello I'm trying to use google visualization API along with django templates system. I got an error that don't know how to fix. The error is the following:

 invalid_block_tag
    raise self.error(token, "Invalid block tag: '%s'" % command)
django.template.TemplateSyntaxError: Invalid block tag: 'endfor'

The code is:

function drawChart() {
        var data = new google.visualization.DataTable();
        data.addColumn('date', 'time');
        data.addColumn('number', 'x');
        data.addColumn('number', 'y');
        data.addColumn('number', 'z');
        data.addRows([
        {% for d in datos &}
        [new Date({{d.instante|date:"Y, m, d, H, i, s"}}), {{d.x}}, {{d.y}}, {{d.z}}]
        {% if not forloop.last %},{% endif %}
        ]);
        {% endfor %}
        var chart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div'));
        chart.draw(data, {displayAnnotations: true});
      }

Thanks you all!

A: 

I've had problems in django where template errors show up when the real problem is an error in generating the data on a previous line. Try checking if the variables you use are a problem - cut them out entirely and see if it works. Then put them in one by one and wait til the error appears again.

fastmultiplication
+2  A: 

You goofed your for tag:

{% for d in datos %}
Ignacio Vazquez-Abrams
+1 django template mode in vim lights this up like a christmas tree
gnibbler