table flask python code example
Example: flask sqlalchemy put data in html table
from flask_table import Table, Col
class ItemTable(Table):
name = Col('Name')
description = Col('Description')
class Item(object):
def __init__(self, name, description):
self.name = name
self.description = description
items = [Item('Name1', 'Description1'),
Item('Name2', 'Description2'),
Item('Name3', 'Description3')]
items = [dict(name='Name1', description='Description1'),
dict(name='Name2', description='Description2'),
dict(name='Name3', description='Description3')]
items = ItemModel.query.all()
table = ItemTable(items)
print(table.__html__())