def edit_car(car_id):
form = CarForm(request.form)
if form.is_valid():
car = Car.query.get_or_404(car_id)
car.from_form(form) # Update car fields
...
# save car in database ...
class Car(db.Model):
color = db.Column(db.String(10))
...
def from_form(self, form):
self.color = form.color.data
... # all other fields
class SpecialCarForm(FlaskForm):
...
def populate_obj(obj):
# mess with data, set extra fields, etc.
# potentially call super after
super().populate_obj(obj)