O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

23.3.1 Configuring the List of Post Objects

Instead of letting the admin app generate PostAdmin for us through a call to site.register(), we can instead use the @register() decorator on a subclass of ModelAdmin, allowing us to configure the set of admin pages using expected attributes. To begin, we can set the list_display attribute, defining which fields in PostAdmin we want displayed, as shown in Example 23.6. Figure 23.6 shows the result of this change.

Example 23.6: Project Code

blog/admin.py in 14e2d2282b

6   @admin.register(Post) 7   class PostAdmin(admin.ModelAdmin): 8       list_display = ('title', 'pub_date')

Figure 23.6: Post List in 14e2d2282b

This change has no effect on the add page, shown in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required