(self, request)
| 22 | super().__init__(**super_kwargs) |
| 23 | |
| 24 | def get_results(self, request): |
| 25 | if SEARCH_VAR not in request.GET: |
| 26 | return super().get_results(request) |
| 27 | |
| 28 | # Note that pagination is 0-based, not 1-based. |
| 29 | sqs = ( |
| 30 | SearchQuerySet(self.haystack_connection) |
| 31 | .models(self.model) |
| 32 | .auto_query(request.GET[SEARCH_VAR]) |
| 33 | .load_all() |
| 34 | ) |
| 35 | |
| 36 | paginator = Paginator(sqs, self.list_per_page) |
| 37 | # Get the number of objects, with admin filters applied. |
| 38 | result_count = paginator.count |
| 39 | full_result_count = ( |
| 40 | SearchQuerySet(self.haystack_connection).models(self.model).all().count() |
| 41 | ) |
| 42 | |
| 43 | can_show_all = result_count <= self.list_max_show_all |
| 44 | multi_page = result_count > self.list_per_page |
| 45 | |
| 46 | # Get the list of objects to display on this page. |
| 47 | try: |
| 48 | result_list = paginator.page(self.page_num).object_list |
| 49 | # Grab just the Django models, since that's what everything else is |
| 50 | # expecting. |
| 51 | result_list = [result.object for result in result_list] |
| 52 | except InvalidPage: |
| 53 | result_list = () |
| 54 | |
| 55 | self.result_count = result_count |
| 56 | self.full_result_count = full_result_count |
| 57 | self.result_list = result_list |
| 58 | self.can_show_all = can_show_all |
| 59 | self.multi_page = multi_page |
| 60 | self.paginator = paginator |
| 61 | |
| 62 | |
| 63 | class SearchModelAdminMixin: |
nothing calls this directly
no test coverage detected