def export_as_xls(modeladmin, request, queryset):
"""
Generic xls export admin action.
"""
if not request.user.is_staff:
raise PermissionDenied
opts = modeladmin.model._meta
wb = Workbook()
ws0 = wb.add_sheet('0')
col = 0
field_names = []
# write header row
for field in opts.fields:
ws0.write(0, col, field._meta.verbose_name)
field_names.append(field._meta.verbose_name)
col = col + 1
如果我尝试导出到 xls,则会出现此错误:
“AutoField”对象没有属性“_meta”
与:field.name
这个工作,但我需要详细的名字