May 2018
Beginner to intermediate
526 pages
11h 57m
English
Now, we will take a look at how to customize the admin site. Edit the admin.py file of your blog application and change it, as follows:
from django.contrib import adminfrom .models import Post@admin.register(Post)class PostAdmin(admin.ModelAdmin): list_display = ('title', 'slug', 'author', 'publish', 'status')
We are telling the Django admin site that our model is registered in the admin site using a custom class that inherits from ModelAdmin. In this class, we can include information about how to display the model in the admin site and how to interact with it. The list_display attribute allows you to set the fields of your model that you want to display in the admin object list page. The @admin.register() ...
Read now
Unlock full access