- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经在 Django 中成功地实现了一些应用程序。目前我尝试根据教程实现图表:http://chartit.shutupandship.com/docs/#how-to-use .
但我只收到此错误消息:
Exception Value: 'NoneType' object has no attribute '__getitem__'
Exception Location: /home/administrator/virtualenvs/django27/lib/python2.7/site-packages/chartit/templatetags/chartit.py in load_charts, line 68
失败出现在这一行: hco['图表']['renderTo'] = render_to
错误是否表明 render_to 不是字典?
模型.py:
Class MonthlyWeatherByCity(models.Model):
month = models.IntegerField()
boston_temp = models.DecimalField(max_digits=5, decimal_places=1)
houston_temp = models.DecimalField(max_digits=5, decimal_places=1)
views.py:
def weather_chart_view(request):
#Step 1: Create a DataPool with the data we want to retrieve.
weatherdata = \
DataPool(
series=
[{'options': {
'source': MonthlyWeatherByCity.objects.all()},
'terms': [
'month',
'houston_temp',
'boston_temp']}
])
#Step 2: Create the Chart object
cht = Chart(
datasource = weatherdata,
series_options =
[{'options':{
'type': 'line',
'stacking': False},
'terms':{
'month': [
'boston_temp',
'houston_temp']
}}],
chart_options =
{'title': {
'text': 'Weather Data of Boston and Houston'},
'xAxis': {
'title': {
'text': 'Month number'}}})
我在模板中包含了脚本文件,{{ load block }} ..
<div id='container'> {{ weatherchart|load_charts:"container" }} </div>
<script type="text/javascript" src="/static/js/jquery-1.11.0.js"></script>
<script type="text/javascript" src="/static/js/highcharts.js"></script>
但我认为这不是问题所在。
我该如何解决?谢谢!
最佳答案
尝试将 {{ weatherchart|load_charts:"container"}}
行从 ID 为 container
的 div
移出并移入header
,比如 example
关于python - 使用 Python 2.7 在 Django 1.6 中实现 chartit - TypeError : 'NoneType' has no attribute __getitem__,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22374701/
我正在使用 Chartit 在我的 Django 网站应用程序中绘制图表,这是我的模板中的内容: {% load chartit %} {{ chart|load_charts:"container"
我正在使用 django 框架开发一个网络应用程序,需要在前端绘制和显示图表。 所以我为此目的使用 django chartit,但是当我运行 django 开发服务器时,它没有显示任何内容,没有空白
我在views.py 文件中遇到Django Chartit 问题,因为他找不到我的表格。但是这个表存在于我的 MySQL 数据库中。 我使用此模块是为了在我的 Django 网站中显示一些图形,这是
我的views.py文件如下: from django.shortcuts import render, render_to_response from chartit import DataPool
我正在开发一个 django 项目,并决定向某些页面添加图表。我选择 Chartit 来完成这项任务。 问题是我想让轴标签和工具提示具有自定义格式,并且我想使用 Highcharts 的格式化程序字段
因此,我尝试用我的数据创建一个数据透视图,但我一直收到“NoneType”对象不可迭代。我正在使用图表。我的错误特别针对“条款”:['tot_ft']}]) 这是特别在数据透视图部分 这是我的代码:以
我正在使用 Django-Chartit创建图表。 试图关注this例子。 我的问题是我想使用不是来自模型的数据所以我尝试了这段代码 data = \ DataPool( ser
我在使用 django-charit 时遇到问题它利用了Highcharts .到目前为止,这是我的代码: #creating chart ds = DataPool( ser
我已经在 Django 中成功地实现了一些应用程序。目前我尝试根据教程实现图表:http://chartit.shutupandship.com/docs/#how-to-use . 但我只收到此错误
我是一名优秀的程序员,十分优秀!