2 from django.contrib.admin.views.main import ChangeList
4 class HTSChangeList(ChangeList):
5 def __init__(self, request, model, list_filter, search_fields,
6 list_per_page, model_admin, extra_filters=None):
7 """Simplification of the django model filter view
9 The new parameter "extra_filter" should be a mapping
10 of that will be passed as keyword arguments to
13 self.extra_filters = extra_filters
16 'request': request, #request
17 'model': model, #model
18 'list_display': [], # list_display
19 'list_display_links': None, # list_display_links
20 'list_filter': list_filter, #list_filter
21 'date_hierarchy': None, # date_hierarchy
22 'search_fields': search_fields, #search_fields
23 'list_select_related': None, # list_select_related,
24 'list_per_page': list_per_page, #list_per_page
25 'list_editable': None, # list_editable
26 'model_admin': model_admin #model_admin
28 if django.VERSION[0] >= 1 and django.VERSION[1] >= 4:
29 args['list_max_show_all'] = 20000, #list_max_show_all
30 super(HTSChangeList, self).__init__(**args)
33 # I removed to field in the first version
35 self.multi_page = True
36 self.can_show_all = False
38 def get_query_set(self, request=None):
40 if django.VERSION[0] >= 1 and django.VERSION[1] >= 4:
41 args['request'] = request #list_max_show_all
43 qs = super(HTSChangeList, self).get_query_set(**args)
44 if self.extra_filters:
45 new_qs = qs.filter(**self.extra_filters)
46 if new_qs is not None: