code: def to_json(content, indent=None):
      
      if isinstance(content, QuerySet):
          json_serializer = serializers.get_serializer('json')()
          serialized_content = json_serializer.serialize(content, ensure_ascii=False, indent=indent)
      else:
          try:
              serialized_content = json.dumps(content, cls=DecimalEncoder, ensure_ascii=False, indent=indent)
          except TypeError:
              # Fix for Django 1.5
              serialized_content = json.dumps(content, ensure_ascii=False, indent=indent)
      return serialized_content
docs: Serializes a python object as JSON
  
      This method uses the DJangoJSONEncoder to to ensure that python objects
      such as Decimal objects are properly serialized. It can also serialize
      Django QuerySet objects.