List display configuration helps you decide what information shows up in the admin list view. It makes it easy to see important details at a glance.
List display configuration in Django
class ModelAdmin(admin.ModelAdmin): list_display = ('field1', 'field2', 'method_name')
list_display is a tuple of field names or method names to show as columns.
Methods used in list_display must be defined inside the ModelAdmin class and return a string or value.
class BookAdmin(admin.ModelAdmin): list_display = ('title', 'author', 'published_date')
class BookAdmin(admin.ModelAdmin): list_display = ('title', 'author', 'is_recent') def is_recent(self, obj): return obj.published_date.year >= 2020 is_recent.boolean = True
class EmptyAdmin(admin.ModelAdmin):
list_display = ()This example shows a Book model with three fields. The admin list view will show the title, author, and a custom column for the year published extracted from the date.
from django.contrib import admin from django.db import models class Book(models.Model): title = models.CharField(max_length=100) author = models.CharField(max_length=100) published_date = models.DateField() class BookAdmin(admin.ModelAdmin): list_display = ('title', 'author', 'published_year') def published_year(self, obj): return obj.published_date.year published_year.short_description = 'Year Published' admin.site.register(Book, BookAdmin)
Time complexity: Displaying list columns is fast because it uses database queries optimized by Django.
Space complexity: Minimal extra memory is used for displaying columns.
Common mistake: Forgetting to add the method to list_display or not returning a value causes errors.
Use list_display to show important fields; use list_filter or search_fields for filtering instead.
list_display controls which fields or methods show as columns in the admin list view.
You can add custom methods to show computed or formatted data.
It helps you quickly see and manage your data in the admin interface.