I'm working with flask and handsontable. I'm interested in dynamically creating data and then passing it to a view for display with handsontable.
So far I have :
@app.route('/mv')
def my_view():
pq = my_object()
# put all of the data into a list
for p in pq:
print p._data
data = [p._data for p in pq]
# render the template with our data
return render_template('my_view.html', page_title = 'nothing yet', data=data)
if __name__ == '__main__':
app.run()
The print statement generates a dictionary of keys values for each object that looks like:
{ 'su': False, 'delete_at': 1440324275.2, 'id': 360, 'created_at': 1440266675.2, }
{ 'su': False, 'delete_at': 1440324275.202, 'id': 361, 'created_at': 1440266675.202, }
{ 'su': False, 'delete_at': 1440324275.203, 'id': 362, 'created_at': 1440266675.203, }
I want to convert the unix time stamps to human readable date times, before ( or after ? ) passing it to the view. What's the best way to do this?
I've come across Converting unix timestamp string to readable date in Python, which shows a possible way to do this with python. Is it better to do this with python or javascript within the view?