def handle(self, *args, **options): months = Months.objects.all() cmps = Company.objects.all() for month in months: for comp in cmps: print CompanyMonthlyRating.calcrating(comp.code, month.code) self.stdout.write( 'Successfully calculated ranking for')
def get(self, request): companies = Company.objects.all() if request.is_ajax(): company = request.GET.get("company") months = Months.objects.all().order_by("id") crs_details = {} for month in months: crs = CompanyMonthlyRating.crs(month.code, company) crs_details[month.code] = crs labels = list(months.values_list("code", flat=True)) data = {"labels": list(months.values_list("code", flat=True)), "data": crs_details} return HttpResponse(json.dumps(data), content_type="application/json") return render(request, "barchart.html", {"companies": companies})