我尝试在Django中使用highcharts来配置图表的显示,但遇到了以下错误:
属性错误:“WSGIRequest”对象没有属性“is_ AJAX ”
编码:
查看次数.py
import random
from django.shortcuts import render
from highcharts.views import HighChartsBarView
class BarView(HighChartsBarView):
title = 'Example Bar Chart'
subtitle = 'my subtitle'
categories = ['Orange', 'Bananas', 'Apples']
chart_type = ''
chart = {'zoomType': 'xy'}
tooltip = {'shared': 'true'}
legend = {'layout': 'horizontal', 'align': 'left',
'floating': 'true', 'verticalAlign': 'top',
'y': -10, 'borderColor': '#e3e3e3'}
@property
def series(self):
result = []
for name in ('Joe', 'Jack', 'William', 'Averell'):
data = []
for x in range(len(self.categories)):
data.append(random.randint(0, 10))
result.append({'name': name, "data": data})
return result
索引.html
{% % load staticfiles %}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="{% static 'js/highcharts/highcharts.js' %}"></script>
<script type="text/javascript">
$(function () {
$.getJSON("{% url 'bar' %}", function(data) {
$('#container').highcharts(data);
});
});
</script>
</head>
<body>
<div id="container" style="height: 300px"></div>
</body>
</html>
我不知道怎么修
1条答案
按热度按时间bgtovc5b1#
Django-braces不支持官方的django 4+:https://pypi.org/project/django-braces/
这个问题已经在github中修复了,但还没有发布。https://github.com/brack3t/django-braces/issues/288
您可以使用pip安装github版本:
我希望有只是这个兼容性问题与django 4+,它将工作