Self hosted FLOSS fitness/workout, nutrition and weight tracker
Use DRF to return the weight chart results
Roland Geider2e4fb688815c
diff --git a/wger/weight/views.py b/wger/weight/views.pyindex 3bbc7149c..05d4fa04f 100644--- a/wger/weight/views.py+++ b/wger/weight/views.py@@ -16,7 +16,6 @@import loggingimport csv-import jsonimport datetimefrom django.shortcuts import render@@ -40,6 +39,8 @@ from django.db.models import Maxfrom django.views.generic import CreateViewfrom django.views.generic import UpdateViewfrom django.forms import widgets+from rest_framework.response import Response+from rest_framework.decorators import api_viewfrom wger.weight.models import WeightEntryfrom wger.weight import helpers@@ -158,6 +159,7 @@ def overview(request):@login_required+@api_view(['GET'])def get_weight_data(request):'''Process the data to pass it to the JS libraries to generate an SVG image@@ -182,8 +184,8 @@ def get_weight_data(request):'y': i.weight,'id': i.id})- # Return the results to the server- return HttpResponse(json.dumps(chart_data), content_type='application/json')+ # Return the results to the client+ return Response(chart_data)CSV_DATE_FORMAT = (('%d.%m.%Y', 'DD.MM.YYYY (30.01.2012)'),