为什么在admin.py中写的字段不可以添加

作者:942431221 411 浏览 1 评论 发布时间:2019-12-31 13:53:53

from import_export import resources
from import_export.admin import ImportExportModelAdmin

from .models import Plant
from django.contrib import admin


class PlantResource(resources.ModelResource):
    class Meta:
        model = Plant
@admin.register(Plant)
class PlantAdmin(ImportExportModelAdmin):
    fields = ('growth_period', 'time', 'date', 'crop_grow_way',
              'plant_type', 'plant_height', 'stem_girth')
    readonly_fields = fields
    list_display = ('plant_type', 'plant_height', 'stem_girth', 'growth_period')
    list_filter = ('plant_type', 'growth_period')
    search_fields = ('plant_type',)
    date_hierarchy = 'create_time'
    actions = ['export_as_excel']  # 增加动作, 对应相应的方法名

添加不了是我的admin.py哪里写错了么

Loading...
评论列表 1条评论
942431221
2020-05-04 18:14:50

知道了,readonly_fields 打扰了