I have experience with PHP but im new to Flask and Python and I need help with a simple thing.
I have a database table and I need each entry in a radio button. I need to use WTForms but I can't do it. The id should be the value and the botname should be the label.
This is my table:
class Probot(db.Model):
__tablename__ = "probot"
id = db.Column(db.Integer, primary_key=True)
botname = db.Column(db.String(20), unique=True, index=True)
is_available = db.Column(db.Boolean, nullable=False, default=True)
battery = db.Column(db.Integer)
registered_on = db.Column(db.DateTime,default=datetime.datetime.utcnow())
I use the query: Probot.query.all() but how do I use the results in the choices atribute of the RadiofField on the form?
class SimpleForm(Form):
example = RadioField('Label', choices=[])
I have tried many ways but I always get errors I would appreciate some help. Thank You.