Add UTF-8 BOM header to Flask-Admin export

A simple trick to add additional bytes prepending Flask’s stream_with_context

 from flask_admin.contrib.sqla import ModelView from itertools import chain class MyAdminView(ModelView): can_export = True column_export_list = ['field1', 'field2'] def _export_csv(self, return_url): r = super(MyAdminView, self)._export_csv(return_url) r.response …

This article is reprinted from: https://blog.est.im/2022/stdout-05
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment