5 Django Admin
This chapter covers
- Using the Django Admin to manage your
Modelcontent - Creating a superuser
- Customizing the Django Admin
- Linking between
Modelobjects in the Django Admin ModelMetaproperties
This chapter covers the Django Admin, a built-in, web-based tool for managing your object relational mapping (ORM) Model objects. The Django Admin gives you screens to list, add, edit, and delete the objects in the database.
5.1 Touring the Django Admin
In the previous chapter, you learned how to use the ORM to add storage capabilities to your Django site. Along the way, you used two techniques to construct data: the .create() method on a Model object and fixtures. Wouldn’t it be nice if you had a graphical interface to manage your objects? Django comes with a tool that does this for you. The Django Admin is a customizable, web-based interface that allows you to create and modify your Model objects with very little code.
Figure 5.1 shows a Django Admin screen that lists all of the Musician objects in the database. The code I wrote to generate that screen is less than 80 lines long. With it, you have multifield sorting, field search, filtering, custom columns, and all the actions you need to be able to add, update, and delete musicians from the database.
Figure 5.1 Parts of the Musician Listing page in the Django Admin