Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectField for child entity #137

Open
zjpiazza opened this issue Jan 7, 2019 · 0 comments
Open

SelectField for child entity #137

zjpiazza opened this issue Jan 7, 2019 · 0 comments

Comments

@zjpiazza
Copy link

zjpiazza commented Jan 7, 2019

I have a data model as follows:

`class Contact(db.Model):

__tablename__ = "contact"

id = db.Column(db.Integer, primary_key=True, autoincrement=True)
first_name = db.Column(db.String(45), nullable=False)
last_name = db.Column(db.String(45), nullable=False)
phone_number = db.Column(db.String(25), nullable=False)
email = db.Column(db.String(45), nullable=False)

def __init__(self, first_name=None, last_name=None, phone_number=None, email=None):
    self.first_name = first_name
    self.last_name = last_name
    self.phone_number = phone_number
    self.email = email

class Organization(db.Model):
tablename = 'organization'

id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String(45), nullable=False)
contact_id = db.Column(db.Integer, db.ForeignKey(Contact.id), nullable=False)
users = db.relationship('User', backref=db.backref('organization', lazy=True))
contacts = db.relationship('Contact', backref=db.backref('organization', lazy=True))

def __init__(self, name, contact_id):
    self.name = name
    self.contact_id = contact_id
    self.display = self.name`

When I generate a form for Organization, I am not presented with a SelectField for the Contact. The documentation is a bit lacking on this topic. Is there an easy way to achieve this functionality?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant