标签:png img search com alt ref mamicode title book
先总结一下命令:
python manage.py createsuperuser
python manage.py runserver 8080
如果想改成中文:编辑setting.py,将英文改成中文
保存之后,刷新浏览器可看到,Booktest里models中BookInfo类被注册了。
添加字段后,刷新浏览器:
修改admin.py文件:
from django.contrib import 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)
标签:png img search com alt ref mamicode title book
原文地址:https://www.cnblogs.com/Lee-yl/p/12444161.html