Get an empty dict & no error when attrs not there
This commit is contained in:
parent
87a658a6b6
commit
8df76219f8
1 changed files with 4 additions and 1 deletions
|
@ -14,6 +14,9 @@ def view(request):
|
||||||
|
|
||||||
returnDict = {}
|
returnDict = {}
|
||||||
for code in FundraisingGoal.objects.filter(fundraiser_code_name__in=codeNames):
|
for code in FundraisingGoal.objects.filter(fundraiser_code_name__in=codeNames):
|
||||||
|
returnDict[code] = {}
|
||||||
for kk in keysForJSON:
|
for kk in keysForJSON:
|
||||||
|
if hasattr(code, kk):
|
||||||
returnDict[code][kk] = getattr(code, kk)
|
returnDict[code][kk] = getattr(code, kk)
|
||||||
|
|
||||||
return JsonResponse( returnDict)
|
return JsonResponse( returnDict)
|
||||||
|
|
Loading…
Reference in a new issue