[Chartjs]-How can I pass my sqlite data to django, and make chart?

1👍

You can send the queryset to the template in the context and use the values there.

class YourTemplate(TemplateView):
    def get_context_data(self, **kwargs):
        requestCnt = ActivityLog.objects.annotate(request_count=Count('requestType')).values('doDate', 'request_count')
        context = super().get_context_data(**kwargs)
        context["data"] = requestCnt
        return context

Then in your template, you can use data variable to get the data for both the axis. The data will be of the format:

[{"doDate":"...", "request_count":"..."}, {"doDate":"...", "request_count":"..."}]

Leave a comment