def donations(request):
'''
actual data from the FEC, propublica data, through the django ORM cache
'''
data = {}
data["representatives"] = {d["id"]: d for d in
Representative.objects.all()
.annotate(name=Concat('first_name', Value(" "), 'last_name'))
.values("id", "name", "party")}
data["committees"] = {d["id"]: d for d in
SuperPAC.objects.all().values("id", "name")}
data["donations"] = list(Donation.objects.all()
.annotate(source=F("superpac_id"), destination=F("representative_id"))
.values("source", "destination", "support")
.annotate(amount=Sum("amount")))
return JsonResponse(data)
评论列表
文章目录