def ajax_request(func):
 @wraps(func)
 def wrapper(request, *args, **kwargs):
  response = func(request, *args, **kwargs)
  if isinstance(response, dict):
   return JsonResponse(response)
  else:
   return response
 return wrapper

def ajax_request ( func ) : @ wraps ( func ) def wrapper ( request , * args , ** kwargs ) : response = func ( request , * args , ** kwargs ) if isinstance ( response , dict ) : return JsonResponse ( response ) else : return response return wrapper
if view returned serializable dict .