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 = {} | ||||
|     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) | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Bradley M. Kuhn
						Bradley M. Kuhn