我正在尝试在django项目中创建数据可视化仪表板,我正在使用highchart js来实现这一点。我的问题是甚至在遵循文档之后,我的数据甚至没有显示为简单的折线图。我肯定错过了什么,请帮助。
我的模特
class Company(models.Model):
name = models.CharField(max_length=100)
phone = models.CharField(max_length=50)
email = models.EmailField(max_length=75)
city = models.ForeignKey(City)
sector = models.ForeignKey(Sector)
description = models.TextField()
def __unicode__(self):
return self.name
class Feedback(models.Model):
PENDING,RESOLVED = range(2)
FEEDBACK_STATUS = (
(PENDING,'Pending'),
(RESOLVED, 'Resolved'),
)
title = models.CharField(max_length=100)
feed_back = models.TextField(verbose_name='feed back')
date_posted = models.DateTimeField(verbose_name='date posted',auto_now_add=True)
customer = models.ForeignKey(Customer)
company = models.ForeignKey(Company)
status = models.PositiveSmallIntegerField(null = True ,choices=FEEDBACK_STATUS, blank = True)
# status = models.BooleanField(default=False)
objects = FeedbackManager()
def __unicode__(self):
return self.title
views.py
def chart_data(request):
"""
this model holds the data visualization datasets
"""
company = Company.objects.get(pk=1)
feedbacks = Feedback.objects.filter(company=company)
feeds = feedbacks.count()
return render_to_response('cfback/dashboard.html',RequestContext(request, {'company':company,
'feeds':feeds}))
在模板方面,我有以下代码 base.html文件 https://codeshare.io/5w9wDD
和dashboard.html是 https://codeshare.io/5zlKvk
你会在dashboard.html上注明 我正在测试来自highcharts的演示图表,并从我的模型中调用变量来测试是否有任何显示,其余的是来自演示应用程序的值。
xAxis: {
categories: [{{company}},{{company}},{{company}},{{company}},{{company}}],
title: {
text: null
}
帮助弄清楚失踪的是什么,过去2天我一直在这。我几乎放弃了高等教育并尝试了其他的东西。 感谢