def determine_format(request, serializer, default_format=u'application/json'):
 format = request.GET.get(u'format')
 if format:
  if (format in serializer.formats):
   return serializer.get_mime_for_format(format)
 if ((u'callback' in request.GET) and (u'jsonp' in serializer.formats)):
  return serializer.get_mime_for_format(u'jsonp')
 accept = request.META.get(u'HTTP_ACCEPT', u'*/*')
 if (accept != u'*/*'):
  try:
   best_format = mimeparse.best_match(serializer.supported_formats_reversed, accept)
  except ValueError:
   raise BadRequest(u'Invalid Accept header')
  if best_format:
   return best_format
 return default_format

def determine_format ( request , serializer , default_format = u'application/json' ) : format = request . GET . get ( u'format' ) if format : if ( format in serializer . formats ) : return serializer . get_mime_for_format ( format ) if ( ( u'callback' in request . GET ) and ( u'jsonp' in serializer . formats ) ) : return serializer . get_mime_for_format ( u'jsonp' ) accept = request . META . get ( u'HTTP_ACCEPT' , u'*/*' ) if ( accept != u'*/*' ) : try : best_format = mimeparse . best_match ( serializer . supported_formats_reversed , accept ) except ValueError : raise BadRequest ( u'Invalid Accept header' ) if best_format : return best_format return default_format
tries to "smartly" determine which output format is desired .