Representing SQLAlchemy model data as a form
First, let’s build a form using a SQLAlchemy model. In this recipe, we will take the product model from our catalog application used previously in this book and add functionality, creating products from the frontend using a web form.
Getting ready
We will use our catalog application from Chapter 4, Working with Views, and we will develop a form for the Product model.
How to do it...
If you recall, the Product model looks like the following lines of code in the models.py file:
class Product(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255))
price = db.Column(db.Float)
category_id = db.Column(db.Integer,
db.ForeignKey('category.id'))
category = db.relationship(
'Category...