From 8df76219f80407a7bd4a90a184b2daf65876fade Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sat, 9 May 2015 17:29:08 -0700 Subject: [PATCH] Get an empty dict & no error when attrs not there --- www/conservancy/apps/fundgoal/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/www/conservancy/apps/fundgoal/views.py b/www/conservancy/apps/fundgoal/views.py index d05ccb7b..f29fe063 100644 --- a/www/conservancy/apps/fundgoal/views.py +++ b/www/conservancy/apps/fundgoal/views.py @@ -14,6 +14,9 @@ def view(request): returnDict = {} for code in FundraisingGoal.objects.filter(fundraiser_code_name__in=codeNames): + returnDict[code] = {} for kk in keysForJSON: - returnDict[code][kk] = getattr(code, kk) + if hasattr(code, kk): + returnDict[code][kk] = getattr(code, kk) + return JsonResponse( returnDict)