admin 应用

admin

注册后台模型(admin.site.register)

app/admin.py

from django.contrib import admin
from . models import Category, Tag, Post

admin.site.register(Category)   
admin.site.register(Tag)
admin.site.register(Post)

定制 Admin 后台(admin.ModelAdmin)

app/admin.py

class PostAdmin(admin.ModelAdmin):
    list_display = ['title', 'created_time', 'modified_time', 'category', 'author']

# 这样将在后台点击一级模型 Post 后,将跳转到二级模型 PostAdmin
admin.site.register(Post, PostAdmin)  

后台视图(admin.site.urls)

projectname/settings.py

from django.contrib import admin

urlpatterns = [
    path('admin/', admin.site.urls),
]

你可能感兴趣的:(admin 应用)