标签:管理系统 默认 创建 name 用户 display 创建用户 sea page
>python manage.py createsuperuser
访问http://127.0.0.1/admin/
app/admin.py 注册需要管理的表
from django.contrib import admin
from app import models
admin.site.register(models.Author)
admin.site.register(models.Publish)
admin.site.register(models.Book)
from django.contrib import admin
from app import models
# Register your models here.
class BookAdmin(admin.ModelAdmin):
list_display = ("id","name","price") #在页面显示指定字段
list_editable = ("name","price") #启用页面编辑功能
filter_horizontal = ("authors",) #启用多对多表的搜索和批量选择功能
list_per_page = 5 #5条记录分页,默认20条
search_fields = ("id","name","price","publish__name") #字段搜索功能
list_filter = ("publish__name",) #按照某给字段过滤
ordering = ("price",) #按照价格排序,ordering = ("-price",)降序
admin.site.register(models.Author)
admin.site.register(models.Publish)
admin.site.register(models.Book,BookAdmin)
LANGUAGE_CODE = 'zh-hans'
标签:管理系统 默认 创建 name 用户 display 创建用户 sea page
原文地址:https://www.cnblogs.com/L-dongf/p/11909340.html