From 8df76219f80407a7bd4a90a184b2daf65876fade 2015-05-10 00:29:08 From: Bradley M. Kuhn Date: 2015-05-10 00:29:08 Subject: [PATCH] Get an empty dict & no error when attrs not there --- diff --git a/www/conservancy/apps/fundgoal/views.py b/www/conservancy/apps/fundgoal/views.py index d05ccb7b938c177c2ee56099a433dfd88f636334..f29fe063209a456b7c89d0ff7a4bc28090e27f8d 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)