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.

Figure 5.1 Parts of the Musician listing page in the Django Admin
CH05 F10 trudeau DjangoIA finished

5.1.1 Creating an admin user

5.1.2 The default Django Admin

5.1.3 Adding your own models

5.2 Customizing a listing page

5.2.1 Sorting and searching

5.2.2 Filtering

5.2.3 New in Django 5: Facets

5.4 Model meta-properties

5.4.1 Sort order

5.4.2 Indexes

5.4.3 Uniqueness

5.4.4 Object names

5.5 Exercises

5.6 Summary

sitemap