1. Milton Mazzarri
  2. django-business-reports

Commits

Milton Mazzarri  committed d561bd7

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

  • Participants
  • Parent commits 4eb6afa
  • Branches pdf-export-geraldo

Comments (0)

Files changed (1)

File dbr/views.py

View file
 
 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"""