views.py 323 Bytes
Newer Older
1
from django.db.models import Count
fred's avatar
fred committed
2 3 4 5 6 7
from django.http import JsonResponse

from .models import PodcastLogLine


def downloads_json(request, *args, **kwargs):
8 9
    qs = PodcastLogLine.objects.values('soundfile').annotate(total=Count('*'))
    content = {x['soundfile']: x['total'] for x in qs}
fred's avatar
fred committed
10
    return JsonResponse(content)