Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Check if there are any weight entries

Roland Geiderb9cc4d29f87d
diff --git a/weight/views.py b/weight/views.py
index e4c1879a4..1c1819ab3 100644
--- a/weight/views.py
+++ b/weight/views.py
@@ -111,12 +111,14 @@ def overview(request):
min_date = WeightEntry.objects.filter(user = request.user).aggregate(Min('creation_date'))['creation_date__min']
max_date = WeightEntry.objects.filter(user = request.user).aggregate(Max('creation_date'))['creation_date__max']
- template_data['min_date'] = 'new Date(%(year)s, %(month)s, %(day)s)' % {'year': min_date.year,
- 'month': min_date.month,
- 'day': min_date.day}
- template_data['max_date'] = 'new Date(%(year)s, %(month)s, %(day)s)' % {'year': max_date.year,
- 'month': max_date.month,
- 'day': max_date.day}
+ if min_date:
+ template_data['min_date'] = 'new Date(%(year)s, %(month)s, %(day)s)' % {'year': min_date.year,
+ 'month': min_date.month,
+ 'day': min_date.day}
+ if max_date:
+ template_data['max_date'] = 'new Date(%(year)s, %(month)s, %(day)s)' % {'year': max_date.year,
+ 'month': max_date.month,
+ 'day': max_date.day}
return render_to_response('weight_overview.html',
template_data,
context_instance=RequestContext(request))