遇到的问题是MANYTOMANY的选项太多,默认的DJANGO一个多选框搞得人蛋疼,
于是作了一个扩展,不是最好的,但方便多啦。。
也是在昨天说过的各个app的admin.py里操作:
from django.forms import CheckboxSelectMultiple # Register your models here. class SiteForm(forms.ModelForm): class Meta: forms.model = Site widgets = { ‘app_name‘: CheckboxSelectMultiple(), } class SiteAdmin(admin.ModelAdmin): list_display = (‘name‘, ‘status‘, ‘change_date‘) search_fields = [‘name‘] form = SiteForm fields = (‘name‘, ‘description‘, ‘app_name‘, ‘status‘)
以前:
现在:
时间: 2024-10-25 03:01:48