I am facing an issue with the FlaskForm's selectField, which is not reading the db each time I visit "/product/add"
If I add a new category in the Category the choice of the selectField will not update the choice until I restart the server.
I would like for these to refresh every time I call the page.
Below is the code for my ProductForm.
class ProductForm(FlaskForm):
allCategories = getCategoryList()
category = SelectField('Category', validators = [DataRequired()], choices = [(category[0], category[1]) for category in allCategories ])
product_name = StringField("Product Name", validators=[DataRequired()])
product_description = StringField("Description", validators=[DataRequired()])
submit = SubmitField("Save Product")
In past I solved this type of issue however there I was using flask_sqlalchemy, and using QuerySelectField I solved. Here I am using MySQl directly to connect, and not able to implement the same solution with it.