Get an empty dict & no error when attrs not there

This commit is contained in:
Bradley M. Kuhn 2015-05-09 17:29:08 -07:00
parent 87a658a6b6
commit 8df76219f8

View file

@ -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:
if hasattr(code, kk):
returnDict[code][kk] = getattr(code, kk)
return JsonResponse( returnDict)