Let's say I have the following models declared:
class Person(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50))
addresses = db.relationship('Address', backref='person',
lazy='dynamic')
class Address(db.Model):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(50))
person_id = db.Column(db.Integer, db.ForeignKey('person.id'))
And I would like to create a view where the user can view and add details to the Person object. I want to have a button to add an address that goes something like:
<a href='{{ url_for('address.create_view',person=get_value(model,'id'))}}' class='btn'>Add</a>
Now my problem is how do set the person_id to the value that was sent? Ideally I would like to hide the person dropdown widget and turn it into a hiddenfield with the value sent. But I would settle for just selecting the correct person from the person drop down list in the address form.
Thank you.