I am trying to pass the data obtained through a select to a table, however I realize that there is a problem with "character encoding", I think.
This example is the data output straight from the function that pulls data from the database:
[{'NOME': 'FULANO', 'BAIRRO': u'Bar\xe3o', 'CIDADE': u'Len\xe7a', 'RUA': u'R. Machado', 'SERVICO': u'Instala\xe7\xe3o', 'ID': '83070'},
Now I render my template with the datas, simple way:
@app.route('/')
def index():
return render_template('index.html',dados=getAllOS())
Output using console log:
[{'NOME': 'FULANO', 'BAIRRO': u'Barão', 'CIDADE': u'Lença', 'RUA': u'R.Machado', 'SERVICO': u'Instalação', 'ID': '83070'},
I can't remove this encoding, it prevents me from using bootstrapTable or DataTable to write my table, as it doesn't identify the column names with the objects.
<table id="table1" data-toggle="true"
data-toolbar="#toolbar"
data-search="true"
data-show-columns="true"
data-pagination="true"
data-height="500">
</table>
<script type="text/javascript">
$(document).ready(function() {
var data = "{{dados}}"
console.log(data);
var columns = [{"field": "ID", "sortable": true, "title": "ID"}, {"field": "NOME", "sortable": true, "title": "NOME"},
{"field": "SERVICO", "sortable": true, "title": "SERVICO"}, {"field": "CIDADE", "sortable": true, "title": "CIDADE"},
{"field": "BAIRRO", "sortable": true, "title": "BAIRRO"},
{"field": "RUA", "sortable": true, "title": "RUA"}];
$('#table1').bootstrapTable({
data: data,
columns: columns
});
} );
</script>