5 Django Admin
This chapter covers
- Using the Django Admin to manage your
Model
content - Creating a superuser
- Customizing the Django Admin
- Linking between
Model
objects in the Django Admin -
Model
Meta
properties
This chapter covers the Django Admin, a built-in web-based tool for managing your 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 different techniques to construct data: the .create()
method on a Model
, 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 eighty lines long, with it you have multi-field sorting, field search, filtering, custom columns, and all the actions you need to be able to add, update, and delete musicians from the database.