November 2015
Beginner to intermediate
840 pages
26h 30m
English
Post ObjectsInstead 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
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 ...
Read now
Unlock full access