Permalink
Browse files

magic-removal: Fixed #1342 -- Added list_per_page option to Admin opt…

…ions. Thanks, Christopher Lenz

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2629 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent c069623 commit a45930b05c1f878ac60c93b9d494d2d378ba7a11 @adrianholovaty adrianholovaty committed Apr 7, 2006
@@ -1,6 +1,6 @@
from django import template
from django.conf import settings
-from django.contrib.admin.views.main import MAX_SHOW_ALL_ALLOWED, DEFAULT_RESULTS_PER_PAGE, ALL_VAR
+from django.contrib.admin.views.main import MAX_SHOW_ALL_ALLOWED, ALL_VAR
from django.contrib.admin.views.main import ORDER_VAR, ORDER_TYPE_VAR, PAGE_VAR, SEARCH_VAR
from django.contrib.admin.views.main import IS_POPUP_VAR, EMPTY_CHANGELIST_VALUE, MONTHS
from django.core.exceptions import ObjectDoesNotExist
@@ -27,7 +27,6 @@
MAX_SHOW_ALL_ALLOWED = 200
# Changelist settings
-DEFAULT_RESULTS_PER_PAGE = 100
ALL_VAR = 'all'
ORDER_VAR = 'o'
ORDER_TYPE_VAR = 'ot'
@@ -589,7 +588,7 @@ def get_query_string(self, new_params={}, remove=[]):
return '?' + '&'.join(['%s=%s' % (k, v) for k, v in p.items()]).replace(' ', '%20')
def get_results(self, request):
- paginator = ObjectPaginator(self.query_set, DEFAULT_RESULTS_PER_PAGE)
+ paginator = ObjectPaginator(self.query_set, self.lookup_opts.admin.list_per_page)
# Get the number of objects, with admin filters applied.
try:
@@ -611,7 +610,7 @@ def get_results(self, request):
full_result_count = self.manager.count()
can_show_all = result_count <= MAX_SHOW_ALL_ALLOWED
- multi_page = result_count > DEFAULT_RESULTS_PER_PAGE
+ multi_page = result_count > self.lookup_opts.admin.list_per_page
# Get the list of objects to display on this page.
if (self.show_all and can_show_all) or not multi_page:
@@ -196,7 +196,7 @@ def has_field_type(self, field_type, follow=None):
class AdminOptions:
def __init__(self, fields=None, js=None, list_display=None, list_filter=None,
date_hierarchy=None, save_as=False, ordering=None, search_fields=None,
- save_on_top=False, list_select_related=False, manager=None):
+ save_on_top=False, list_select_related=False, manager=None, list_per_page=100):
self.fields = fields
self.js = js or []
self.list_display = list_display or ['__str__']
@@ -206,6 +206,7 @@ def __init__(self, fields=None, js=None, list_display=None, list_filter=None,
self.search_fields = search_fields or []
self.save_on_top = save_on_top
self.list_select_related = list_select_related
+ self.list_per_page = list_per_page
self.manager = manager or Manager()
def get_field_sets(self, opts):

0 comments on commit a45930b

Please sign in to comment.