

You may be wondering why I called the above table the "basic" table, given that it has all the features you may wish to have in a table. The second change is to set the orderable option to false for the Address and Phone Number columns, which removes the clickable sorting headers on these two columns. This will remove these columns when the library looks for matches to a search string given in the search box. I've made two customizations, first I set the searchable column option to false for the Age, Address and Phone Number columns. For the columns that do not need customization the null value is given. The columns option accepts an array of sub-options for each column in the table. Here is the bootstrap_table.html template: This is entirely optional, but in my case it makes sense because I use Bootstrap in most of my projects, and I want my tables to have a look that is consistent with the rest of the page.

The template name is bootstrap_table.html because I will be using the Bootstrap CSS framework to provide the basic table styling. Return render_template('bootstrap_table.html', title='Bootstrap Table', The application is going to have a single route, which passes the query with all the users stored in the database to a Jinja template for rendering: index(): Name = db.Column(db.String(64), index=True)Įmail = db.Column(db.String(120), index=True) Id = db.Column(db.Integer, primary_key=True)

Here is the SQLAlchemy model that I'm going to use for the database: class User(db.Model): The table is going to contain contain information about users. I am going to start from the beginning, so the first step is to create a small Flask application that renders a plain table. Check it out here! How to Render a Table in Flask Update: I have now released an update to this article, including support for editing table cells.

I will only be showing the interesting snippets here, so if you intend to run the code locally you should clone this repository, create a virtual environment and install the requirements.txt file in it. All the code presented in this article comes from my flask-tables repository on GitHub.
