[Chartjs]-How to query database and display on charts.js in django

0👍

Found the way to query

views.py

from django.db.models import Count
    def dashboard(request):
        
      mar_count = Marketplace.objects.annotate(infringement_count=Count('infringement'))

        context= {'mar_count': mar_count}
      return render(request, 'base/dashboard.html', context)

dashboard.html

{% for m in mar_count %}'{{m.infringement_count}}',{% endfor %}

Leave a comment