[Fixed]-"Show all" for more than 200 items in Django Admin

22đź‘Ť

You can change the list_max_show_all and list_per_page attributes on your admin class.

class FooAdmin(admin.ModelAdmin):
    list_max_show_all = 500
    list_per_page = 200

Works with Django 1.4 and newer. See the manual.

0đź‘Ť

Not sure it’s what you’re looking for when you say “on demand” modification of list_per_page, but you could almost certainly query a database. It’d be rather unwieldy, but depending on your use case, administrators could log in, modify their preference, and then proceed to whatever model actually matters.
For example:

#models.py
class PageLength(models.Model):
     page_length = models.IntegerField()

#admin.py

class FooAdmin(admin.ModelAdmin):
     list_per_page = PageLength.objects.get(pk=1) 
👤rattray

0đź‘Ť

*Show all link appears if list_max_show_all value is more than or equal to total items while Show all link disappears if list_max_show_all value is less than total items. *list_max_show_all is 200 by default.

So, you need to set a higher value than 200 (Default) to list_max_show_all to show Show all link to list all items as shown below and you need to set list_per_page to list the specific number of items on each paginated Change List page. By default, 100 is set to list_per_page.

# "admin.py"

@admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
    list_max_show_all = 400 # Changes from 200 (Default) to 400  
    list_per_page = 300 # Changes from 100 (Default) to 300

Leave a comment