def allow_api_profiling(handler):
 if (not settings.DEBUG):
  return handler
 else:
  def aap_wrapper_fn(request, *args, **kwargs):
   response = handler(request, *args, **kwargs)
   if ((not request.is_ajax()) and (response['Content-Type'] == 'application/json')):
    response.content = ('<body>%s</body>' % response.content)
    response['Content-Type'] = 'text/html'
   return response
  return aap_wrapper_fn

def allow_api_profiling ( handler ) : if ( not settings . DEBUG ) : return handler else : def aap_wrapper_fn ( request , * args , ** kwargs ) : response = handler ( request , * args , ** kwargs ) if ( ( not request . is_ajax ( ) ) and ( response [ 'Content-Type' ] == 'application/json' ) ) : response . content = ( '<body>%s</body>' % response . content ) response [ 'Content-Type' ] = 'text/html' return response return aap_wrapper_fn
for api requests decorated with this decorator .