Skip to content

使用python3.8+django3.0.3+xadmin2.0.1,在adminx.py文件中设置list_export_fields控制excel导出字段无效 #712

Description

@awe1233

list_display = ['device_id', 'device_name', 'device_place', 'device_count', 'created_time', 'owner', 'priority',
'department', 'process', 'repair_time', 'operator_acceptance', 'operator_report',
]

list_export = ('xls', 'csv', 'xml', 'json')
list_export_fields = ('device_id',)
但是导出的excel是全部字段都导出

源代码如下:
class Device_Repair_Admin(object):

def operator_acceptance(self, obj):
    return format_html(
        '<a href="{}">验收</a>',
        reverse('repair_app:repair_acceptance', args=(obj.device_id,))
    )

operator_acceptance.short_description = '验收'

def operator_report(self, obj):
    return format_html(
        '<a href="{}">上报</a>',
        reverse('repair_app:repair_report', args=(obj.device_id,))
    )

operator_report.short_description = '上报'

def operator_repair(self, obj):
    return format_html(
        '<a href="{}">进行维修</a>',
        reverse('repair_app:repair_approve', args=(obj.device_id,))
    )

operator_repair.short_description = '操作'

list_display = ['device_id', 'device_name', 'device_place', 'device_count', 'created_time', 'owner', 'priority',
                'department', 'process', 'repair_time', 'operator_acceptance', 'operator_report',
                ]

list_export = ('xls', 'csv', 'xml', 'json')
pdb.set_trace()
list_export_fields = ('device_id',)

show_bookmarks = False

fields = ['device_id', 'device_name', 'device_place', 'device_count', 'priority',
                'department', 'process', 'repair_time', ]

list_filter = ['created_time', 'process', ]

def save_models(self):
    self.new_obj.owner = self.request.user
    return super(Device_Repair_Admin, self).save_models()

Activity

  1. changed the title [-]使用xadmin2.0.1,在adminx.py文件中设置list_export_fields控制excel导出字段无效[/-] [+]使用python3.8+django3.0.3+xadmin2.0.1,在adminx.py文件中设置list_export_fields控制excel导出字段无效[/+] on Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions