@cached_property<EOL><INDENT>def get_queryset(self):<DEDENT>
if hasattr(self, "<STR_LIT>") and self.queryset:<EOL><INDENT>return self.queryset<EOL><DEDENT>self.set_mongonaut_base()<EOL>self.set_mongoadmin()<EOL>self.document = getattr(self.models, self.document_name)<EOL>queryset = self.document.objects.all()<EOL>if self.mongoadmin.ordering:<EOL><INDENT>queryset = queryset.order_by(*self.mongoadmin.ordering)<EOL><DEDENT>q = self.request.GET.get('<STR_LIT:q>')<EOL>queryset = self.get_qset(queryset, q)<EOL>try:<EOL><INDENT>self.page = int(self.request.GET.get('<STR_LIT>', '<STR_LIT:1>'))<EOL><DEDENT>except ValueError:<EOL><INDENT>self.page = <NUM_LIT:1><EOL><DEDENT>obj_count = queryset.count()<EOL>self.total_pages = math.ceil(obj_count / self.documents_per_page)<EOL>if self.page > self.total_pages:<EOL><INDENT>self.page = self.total_pages<EOL><DEDENT>if self.page < <NUM_LIT:1>:<EOL><INDENT>self.page = <NUM_LIT:1><EOL><DEDENT>start = (self.page - <NUM_LIT:1>) * self.documents_per_page<EOL>end = self.page * self.documents_per_page<EOL>queryset = queryset[start:end] if obj_count else queryset<EOL>self.queryset = queryset<EOL>return queryset<EOL>
Replicates Django CBV `get_queryset()` method, but for MongoEngine.