python - Empty Template while drawing graphs using Django-graphos -
i new django. want draw google graph using django graphos. have written small code , getting empty template..any lead appritiated..
view.py
from graphos.renderers import gchart django.shortcuts import render django.shortcuts import render_to_response graphos.sources.model import modeldatasource models import mycityviews def get_context_data(self): queryset = mycityviews.objects.all() data_source = modeldatasource(queryset,fields=['city', 'views']) line_chart = gchart.linechart(data_source) context = {"chart": line_chart} return render_to_response('gchart.html', {'chart': line_chart})
models.py
from django.db import models # create models here. class mycityviews(models.model): city = models.charfield(max_length = 30, blank = true , null = true) views = models.integerfield() class meta: ordering = ['city'] verbose_name = 'city' verbose_name_plural = 'city' def __unicode__(self): return self.city
gchart.html
<!doctype html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta charset="utf-8"> <title>graphos</title> {% load static staticfiles %} <link rel="stylesheet" href="{% static "css/bootstrap.css" %}"> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]}); google.setonloadcallback({{line_chart.as_html}}); </script> </head> <body> {{line_chart.as_html}} <div id="container"></div> </body> </html>
where doing wrong...
did not pass view object div block thats why not getting html view.
<body> <div id="container"> {{line_chart.as_html}} </div> </body>
Comments
Post a Comment