everyone. I have views.py here, I want to calculate different status' tasks and output to chart.js pie-chart. I have tried many ways but none of them works. I have an error saying my views def didn't return HttpResponse, can anyone tell me what it is, please? I used template tags in HTML.
Thanks.
views.py
def visualisation(request, project_id):
project = Project.objects.get(id=project_id)
counts_data = Todo.objects.annotate(
to_do_count = Count('id', filter=Q(status='to_do')),
in_progress_count = Count('id', filter=Q(status='in_progress')),
done_count = Count('id', filter=Q(status='done'))
).order_by('-to_do_count')
context = {'counts_data', counts_data}
return render(request, 'todo_lists/progress.html', context)
html
data: {
labels: [1,2,3],
datasets: [{
label: '# of Votes',
data:[{% for todo in counts_data %} {{ todo }}, {% endfor %}],,
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)'
],
borderWidth: 1
}]
},
There is a def function that has the same name and did not have return sentence, delete it and the issue is gone. @sintribu cheers