bookstore/admin.py
from django.contrib import admin from .models import Book # Register your models here. # admin.site.register(Book)
![image](https://www.www.zyiz.net/i/l/?n=20&i=blog/1847830/202108/1847830-20210813091100380-
1343933388.png)
from django.contrib import admin from .models import Book # Register your models here. # class BookMaage(admin.ModelAdmin): list_display=['id','title','pub','price'] admin.site.register(Book,BookMaage)
from django.contrib import admin from .models import Book # Register your models here. class BookMaage(admin.ModelAdmin): list_display=['id','title','pub','price'] #过滤器 分类查询 list_filter=['pub'] admin.site.register(Book,BookMaage)
from django.contrib import admin from .models import Book # Register your models here. # class BookMaage(admin.ModelAdmin): list_display=['id','title','pub','price'] #添加搜索框[模糊搜索] search_fields=['title'] admin.site.register(Book,BookMaage)
from django.contrib import admin from .models import Book # Register your models here. # class BookMaage(admin.ModelAdmin): list_display=['id','title','pub','price'] #控制 list_display中的字段,可以链接到修改页 ,必须是list_display中 list_display_links=['title'] #过滤器 分类查询 list_filter=['pub'] #添加搜索框[模糊搜索] search_fields=['title'] #添加可编辑字段 list_editable=['price'] admin.site.register(Book,BookMaage)