@admin.register(BuildFunction) class BuildFunctionAdmin(SimpleHistoryAdmin, ImportExportModelAdmin): form = BuildFunctionForm list_display = ('id', 'classification', 'name', 'key', 'default_value', 'user', 'create_time', 'update_time') fields = ('classification', 'name', 'key', 'func_type', 'description', 'default_value') history_list_display = ("default_value",) def get_export_data(self, file_format, queryset, *args, **kwargs): """ 重构该方法,输出数据编码 """ request = kwargs.pop("request") resource_class = self.get_export_resource_class() data = resource_class(**self.get_export_resource_kwargs(request)).export(queryset, *args, **kwargs) export_data = file_format.export_data(data).decode("unicode_escape") return export_data
在继承 ImportExportModelAdmin 类后,需要重写方法 get_export_data 将导出数据使用unicode_escape解码即可
标签:ImportExportModelAdmin,get,django,乱码,export,kwargs,data,class From: https://www.cnblogs.com/fuchenjie/p/16779483.html