Extending Django’s Admin Interface

As we’ve said a few times before, Django’s admin interface is one of the framework’s “killer features,” and most Django developers find it time-saving and useful. Because the admin interface is so popular, it’s common for Django developers to want to customize or extend it.

Before proceeding with this chapter, consider reviewing that material; it covers how to customize the admin interface’s change lists and edit forms, as well as an easy way to “rebrand” the admin interface to match your site.

Obviously, the admin interface is extremely useful for editing data (fancy that). If you have any sort of data entry task, the admin interface simply can’t be beat. We suspect that the vast majority of readers of this book will have a whole host of data entry tasks. Django’s admin interface especially shines when nontechnical users need to be able to enter data; that’s the purpose behind the feature, after all. At the newspaper where Django was first developed, development of a typical online feature — a special report on water quality in the municipal supply, say — goes something like this:

 

  • The reporter responsible for the story meets with one of the developers and goes over the available data.
  • The developer designs a model around this data and then opens up the admin interface to the reporter.
  • While the reporter enters data into Django, the programmer can focus on developing the publicly accessible interface (the fun part!).

In other words, the raison d’être of Django’s admin interface is facilitating the simultaneous work of content producers and programmers. However, beyond the obvious data entry tasks, we find the admin interface useful in a few other cases:

 

  • Inspecting data models: The first thing we do when we’ve defined a new model is to call it up in the admin interface and enter some dummy data. This is usually when we find any data modeling mistakes; having a graphical interface to a model quickly reveals problems.
  • Managing acquired data: There’s little actual data entry associated with a site like http://chicagocrime.org, since most of the data comes from an automated source. However, when problems with the automatically acquired data crop up, it’s useful to be able to go in and edit that data easily.

Django’s admin interface handles these common cases with little or no customization. As with most design tradeoffs, though, handling these common cases so well means that Django’s admin interface doesn’t handle some other modes of editing as well.

We’ll talk about the cases Django’s admin interface isn’t designed to cover a bit later on, but first, let’s briefly digress to a discussion on philosophy.

Back to Tutorial

Share this post
[social_warfare]
Assumptions
The Zen of Admin

Get industry recognized certification – Contact us

keyboard_arrow_up