Admin List Pagination

A snippet showing how to customize admin list pagination.


# models.py

from django.db import models

class Order(models.Model):
    order_id = models.CharField(max_length=20, unique=True)
    customer = models.CharField(max_length=120)
    total = models.DecimalField(max_digits=8, decimal_places=2)
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"Order {self.order_id}"
  

# admin.py

from django.contrib import admin
from .models import Order

@admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
    list_display = ('order_id', 'customer', 'total', 'created_at')
    list_per_page = 25  # Number of items per page
    list_max_show_all = 200  # Max items shown when clicking “Show all”
  
Explanation:
  • Use list_per_page to control how many objects appear per page in the admin list.
  • list_max_show_all prevents “Show all” from loading too many rows at once.
  • Helps improve admin usability and performance on large datasets.
  • Category Admin
  • Total Views 883
  • Last Modified 11 December, 2025
  • Tags #admin #pagination #list #customization
Never miss a story on Django.wiki

Subscribe for fresh tutorials, snippets, and updates.

By subscribing you agree to our Privacy Policy.