Extending the Django Admin - Beyond the Basics

Jacinda Shelly

Audience level:



The admin interface is widely considered a "killer feature" of Django. At its most basic, you can just register all your models and be on your way, but there's so much more available within Django's admin. In this tutorial, we cover intermediate-advanced usage of the Django admin by extending the admin for use at a fictional library.


All Hail the Admin

It is a truth universally acknowledged that the admin is a critical feature of the Django framework, and knowing how to make efficient use of it can save you days or weeks of development for larger sites. The Django tutorial is a great place to take your first steps with the admin, but it can often take a bit of searching to learn how to use some of the more advanced features of the admin. Here we attempt to cover the most useful methods of customizing the admin interface in a hands-on way.

In this tutorial, we will build an admin interface to support the librarians at a local library. The interface will allow them to add and edit patrons and resources (books, CDs, DVDs, etc.) as well as manage fines for overdue items. They will be able to make comments on various models as well.

The goal of this tutorial is to provide working examples of major items in the Django admin documentation in the context of a fully functional Django project.

  • Library Description
    • Describe the models and views in our library project
  • Brief Tutorial Admin Review
    • Fields, Fieldsets, Inlines, List Display, List Filter
  • Customizing the Admin
    • Using callables for list_display and readonly_fields
      • Using list_editable
    • Using Custom Filters
    • Forms
      • Modifying the default
      • Custom creation and edit forms
      • Custom validation
    • Linking between models
    • Dynamic Ordering
    • Admin Templates
      • All the blocks!
    • A convenient notes implementation
  • Admin-Specific Performance Consideration
  • Questions