code: def query_mongo_sort_decend(
          database_name,
          collection_name,
          query={},
          skip=0,
          limit=getattr(
              settings,
              'MONGO_LIMIT',
              200),
      return_keys=(),
          sortkey=None):
      l = []
      response_dict = {}
      try:
          mongodb_client_url = getattr(settings, 'MONGODB_CLIENT',
                                       'mongodb://localhost:27017/')
          mc = MongoClient(mongodb_client_url,document_class=OrderedDict)
          db = mc[str(database_name)]
          collection = db[str(collection_name)]
          if return_keys:
              return_dict = {}
              for k in return_keys:
                  return_dict[k] = 1
              mysearchresult = collection.find(
                  query, return_dict).skip(skip).limit(limit).sort(
                  sortkey, DESCENDING)
          else:
              mysearchresult = collection.find(query).skip(
                  skip).limit(limit).sort(sortkey, DESCENDING)
          response_dict['code'] = 200
          response_dict['type'] = "search-results"
          for d in mysearchresult:
              d['id'] = d['_id'].__str__()
              del d['_id']
              l.append(d)
          response_dict['results'] = l
      except:
          print("Error reading from Mongo")
          print(str(sys.exc_info()))
          response_dict['num_results'] = 0
          response_dict['code'] = 500
          response_dict['type'] = "Error"
          response_dict['results'] = []
          response_dict['message'] = str(sys.exc_info())
      return response_dict