0👍
Try removing <script></script>
tag either from base.html
or api_chart.html
before and after jQuery block.
And also import Chart.js and define id = "myChart"
before using new Chart
.
<h1>Hello World</h1>
<canvas id="myChart" width="400" height="400"></canvas>
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
{% block jQuery %}
<script>
var ctx = document.getElementById('myChart')
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: [
.....
{% endblock %}
Source:stackexchange.com