Reputation: 4440
I am programming my first website with flask one of my sections is a list of all sub-users for the teacher's class so how can I use prettytable with flask to get a table my end goal is a table that looks like this (just the data)
Teacher | Student | Id | GPA | Last sign learned
----------------------------------------------------------------
Medina | John doe | 19500688 | 4.0 | Bad
Medina | Samantha babcock | 91234094 | 2.5 | Toilet
Jonson | Steven smith | 64721881 | 3.0 | Santa
How can I do this preferably with Pretty table but any method would be great!
Upvotes: 0
Views: 1443
Reputation: 4440
Hello so your form is simple to create but so lets begin with static information with python
def function():
from prettytable import *
table = PrettyTable(["Teacher","Student"," ID","GPA"," Last sign learned "])
table.add_row(["Medina","John doe","19500688","4.0","Bad"])
table.add_row(["Medina","Samantha babcock ","91234094","2.5","Toilet"])
table.add_row(["Jonson","Steven smith","64721881","3.0","Santa"])
return render_template("info.html", tbl=table.get_html_string(attributes = {"class": "foo"}))
Now for you HTML:
{%extends "template.html"%}
{{tbl|safe}}
Upvotes: 1