1 from __future__ import absolute_import, print_function, unicode_literals
4 from django.contrib.admin.views.main import ChangeList
6 class HTSChangeList(ChangeList):
7 def __init__(self, request, model, list_filter, search_fields,
8 list_per_page, model_admin, extra_filters=None):
9 """Simplification of the django model filter view
11 The new parameter "extra_filter" should be a mapping
12 of that will be passed as keyword arguments to
15 self.extra_filters = extra_filters
18 'request': request, #request
19 'model': model, #model
20 'list_display': [], # list_display
21 'list_display_links': None, # list_display_links
22 'list_filter': list_filter, #list_filter
23 'date_hierarchy': None, # date_hierarchy
24 'search_fields': search_fields, #search_fields
25 'list_select_related': None, # list_select_related,
26 'list_per_page': list_per_page, #list_per_page
27 'list_editable': None, # list_editable
28 'model_admin': model_admin #model_admin
30 if django.VERSION[0] >= 1 and django.VERSION[1] >= 4:
31 args['list_max_show_all'] = 20000, #list_max_show_all
32 super(HTSChangeList, self).__init__(**args)
35 # I removed to field in the first version
37 self.multi_page = True
38 self.can_show_all = False
40 def get_queryset(self, request=None):
42 if django.VERSION[0] >= 1 and django.VERSION[1] >= 4:
43 args['request'] = request #list_max_show_all
45 qs = super(HTSChangeList, self).get_queryset(**args)
46 if self.extra_filters:
47 new_qs = qs.filter(**self.extra_filters)
48 if new_qs is not None: