Django--admin
admin创建用户
python manage.py createsuperuser
Usernaem:
Email:
Password:
password(again):
Superuser created successfully
Django admin:关于数据库的一个后台管理工具
from django.contrib import admin from app01 import models # Register your models here. class BookAdmin(admin.ModelAdmin): list_display = ("id","name","price","pub_date") # 显示id name price pub_data # list_editable = ("name","price","pub_date") # 直接修改 name price pub_date filter_horizontal = ("authors",) #作者兰水平选择 常用的,因为好看 # filter_vertical = ("authors",) # 作者兰垂直选择 不常用,因为不好看 # list_per_page = 3 #每页显示3条信息 search_fields = ("id","name","publish__name") #搜索,以id name 出版时间来搜索 list_filter = ("pub_date","publish") #按日期和出版社来搜多 # ordering = ("price","id",)# 按照价格字段升序排序 如果price相同,再按id排 ordering = ("-price",)# 按照价格字段降序排序 fieldsets = [ (None,{"fields":["name"]}), ("price information",{"fields":["price","publish"],"classes":["collapse"]}), ] admin.site.register(models.Book,BookAdmin) admin.site.register(models.Author) admin.site.register(models.Publish)