Changeset 299
- Timestamp:
- Apr 7, 2011, 6:07:28 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
django_apps/running/views.py
r298 r299 42 42 user = get_object_or_404(User, pk=user_id) 43 43 result_list = Result.objects.filter(user=user).values_list('date', 'distance') 44 45 total_list = {} 46 for (date,distance) in result_list: 47 key = date.strftime("%Y-%m") 48 if total_list.has_key(key): 49 total_list[key] += distance 50 else: 51 total_list[key] = distance 52 44 53 json_object = { 'label' : [] , 'data' : [] } 45 for (date,distance) in result_list:46 json_object['label'].append( str(date))54 for (date,distance) in total_list.iteritems(): 55 json_object['label'].append(date) 47 56 json_object['data'].append(float(distance)) 48 57 data = json.dumps(json_object, ensure_ascii=False, indent=2)
Note:
See TracChangeset
for help on using the changeset viewer.