Zach
Zach

Reputation: 429

Template Syntax Error with Django - Chartit

I am having problems using Django-Chartit.I am wanting to make a graph using data (points and awards) from my database. I keep getting a Template Syntax Error.Could not parse the remainder: ': container' from 'studentdata|load_charts: container'

Help is much appreciated. Thank you for looking.

Models.py

from django.shortcuts import render_to_response
from students.models import Students
from django.utils import simplejson
import json


 class Students(models.Model):

 CLASS_CHOICES = (
    (u'Yoga','Yoga'),
    (u'Spanish', 'Spanish'),
    (u'French', 'French'),
    (u'Dance', 'Dance'),
  )

  name = models.CharField(max_length=30)
  points = models.IntegerField(max_length=4)
  classname = models.CharField("Class Name",max_length=20, choices = CLASS_CHOICES)
  number = models.CharField("Phone Number", max_length = 20)
  awards = models.IntegerField(max_length=4)

views.py

def display_graph(request):
  classroomdata = \
     DataPool(
        series =
         [{'options' : {
              'source': Students.objects.all()},
              'terms': [
              'awards',
               'points']}
            ])
  cht = Chart(
    datasource = classroomdata,
    series_options = [{'options': {
                        'type': 'line',
                        'stacking': False},
                        'terms': {
                           'awards': ['points']
                         }}],
    chart_options = 
       {'title': {
               'text': 'Data'},
         'xAxis': {
            'title': {
               'text': 'Student'}}})


  return render_to_response('display_graph.html',{'studentdata': cht})

display_graph.html

 !DOCTYPE HTML>
 <html lang="en-US">
 <head>

  <script type = "text/javascript" src = "{{ STATIC_URL }}Highcharts-  2.2.1/js/highcharts.js"></script>
  <script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js">   </script>
  <script type = "text/javascript" src = "{{ STATIC_URL }}jquery-1.7.1.min.js"></script>


{% load chartit %} 
{{ studentdata|load_charts: container}}

</head>

<body>

<div id = "container">
</div>
</body>

Upvotes: 0

Views: 1384

Answers (2)

mariok
mariok

Reputation: 21

container must be enclosed in double quotes like so:

{{studentdata|load_charts:"container"}}

Upvotes: 2

Alasdair
Alasdair

Reputation: 308829

I'm not certain that this is causing the error, but try removing the space before your filter argument.

{{ studentdata|load_charts:container}}

Upvotes: 0

Related Questions