code: def get_directories(self, request):
          
  
          queryset = self.folder.media_folder_children.all().order_by(*config.MEDIA_FOLDERS_ORDER_BY.split(","))
  
          paginator = Paginator(queryset, self.objects_per_page)
  
          page = request.GET.get('page', None)
  
          try:
              object_list = paginator.page(page)
          except PageNotAnInteger:
  
              if page == "all":
                  object_list = queryset
              else:
                  object_list = paginator.page(1)
  
          except EmptyPage:
              object_list = paginator.page(paginator.num_pages)
  
          return object_list
docs: Return directories