So I am trying to add a select field that is dynamic and gets its data from a json file.
class CreateDelivery(FlaskForm):
manufacturer = SelectField("Manufacturer", coerce=str)
def manu_list(self):
with open("manufacturers.json", "r") as file:
manu = json.load(file)
form = CreateDelivery()
form.manufacturer.choices = [(i['name'], i['data']) for i in manu['manufacturers']]
I looked at the docs and wrote this after reading it but I am still not getting any data in the Field. What am I missing to get the data in?
manu_listfunction? I assume you are using this example wtforms.readthedocs.io/en/2.2.1/fields/… Notice how theedit_userfunction is not part of theUserDetailsform class. - gla3drCreateDeliveryor would I call it from its route? - Evan M