I created an Issue.
I made a chart using Morris JS
Question:HowdoIreturnget_status_displayinjson?
importjsonfromdjango.db.modelsimportCountfromdjango.core.serializers.jsonimportDjangoJSONEncoderfromdjango.httpimportHttpResponsefrom.modelsimportProposaldefproposal_per_status_json(request):'''Quantidadedeorçamentosporstatus'''data=Proposal.objects.values('status')\.annotate(value=Count('status'))\.order_by('status').values('status','value')'''Precisareescreverodicionáriocomoscamposdográfico,quesão:'label'e'value'.'''data=[{'label':x['status'],'value':x['value']}forxindata]s=json.dumps(list(data),cls=DjangoJSONEncoder)returnHttpResponse(s)
link
[{"label": "a", "value": 11}, {"label": "c", "value": 9}, {"label": "co", "value": 28}, {"label": "elab", "value": 9}, {"label": "p", "value": 14}]
But I wanted to
[{"label": "aprovado", "value": 11}, {"label": "cancelado", "value": 9}, {"label": "concluído", "value": 28}, {"label": "em elaboração", "value": 9}, {"label": "pendente", "value": 14}]
STATUS_FILTER = (
('c', 'cancelado'),
('elab', 'em elaboração'),
('p', 'pendente'),
('co', 'concluido'),
('a', 'aprovado')
)