Commits

Milton Mazzarri committed d561bd7

Fix the 'list index out of range' error when 'date_hierarchy' field are not filled

Comments (0)

Files changed (1)

 
 def get_date_hierarchy(report_id):
     """Return the date hierarchy for the report"""
-    return DateHierarchy.objects.filter(report=report_id)[0].date
+    date_hierarchy = DateHierarchy.objects.filter(report=report_id)
+    if date_hierarchy:
+        return date_hierarchy[0].date
+    else:
+        return None
 
 def view_report(request, slug, template_name="reporting/view.html"):
     """HTML View of the report"""