django入门(2)----管理数据库站点
时间:2021-07-01 10:21:17
帮助过:22人阅读
admin
from .models import BookInfo,HeroInfo
# Register your models here.
#嵌入类,继承StackdInline
class HeroInfoInline(admin.StackedInline):
model =
HeroInfo #将model属性指向HeroInfo类
extra = 2
#希望额外添加几个数据
class BookInfoAdmin(admin.ModelAdmin):
list_display = [‘id‘,‘btitle‘,‘bpub_date‘
]
list_filter = [‘btitle‘
]
search_fields = [‘btitle‘
]
list_per_page = 1
inlines =
[HeroInfoInline]
admin.site.register(BookInfo,BookInfoAdmin)
admin.site.register(HeroInfo)
django入门(2)----管理数据库站点
标签:png img search com alt ref mamicode title book