Issue
I want to use the first and last name in the user selection.
def user_query():
return User.query
class User(UserMixin, db.Model):
id = db.Column(db.Integer, primary_key=True)
firstname = db.Column(db.String(20))
lastname = db.Column(db.String(20))
class task_add(FlaskForm):
user_responsible = QuerySelectField("responsible", query_factory=user_query, allow_blank=True, get_label='firstname')
In attribute get_label is it possible to have just one column?
Solution
I tbink column property is what you need. Add this to your user model and filter on fullname. See https://docs.sqlalchemy.org/en/14/orm/mapping_columns.html#using-column-property-for-column-level-options.
fullname = column_property(firstname + " " + lastname)
Answered By - gittert
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.