diff --git a/superset/views/base.py b/superset/views/base.py index 02aaf8daef3b5..73627d0463fcf 100644 --- a/superset/views/base.py +++ b/superset/views/base.py @@ -336,3 +336,10 @@ def apply(self, query, func): # noqa perms = self.get_view_menus('datasource_access') # TODO(bogdan): add `schema_access` support here return query.filter(self.model.perm.in_(perms)) + + +class CsvResponse(Response): + """ + Override Response to take into account csv encoding from config.py + """ + charset = conf.get('CSV_EXPORT').get('encoding', 'utf-8') diff --git a/superset/views/core.py b/superset/views/core.py index 72d2cf6cafbb5..faa61ad4374a4 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -43,8 +43,8 @@ from .base import ( api, SupersetModelView, BaseSupersetView, DeleteMixin, - SupersetFilter, get_user_roles, json_error_response, get_error_msg -) + SupersetFilter, get_user_roles, json_error_response, get_error_msg, + CsvResponse) config = app.config stats_logger = config.get('STATS_LOGGER') @@ -959,7 +959,7 @@ def explore_json(self, datasource_type, datasource_id): return json_error_response(DATASOURCE_ACCESS_ERR, status=404) if request.args.get("csv") == "true": - return Response( + return CsvResponse( viz_obj.get_csv(), status=200, headers=generate_download_headers("csv"),