Open mark0978 opened 6 years ago
I have located this https://wtforms-alchemy.readthedocs.io/en/latest/relationships.html#one-to-many-relations However either there is too little functionality there, or the documentation is a bit too skinny since I see no way to use that to accomplish the list filtering that I am doing above.
So, the full problem: I have a FK relationship to another model (from Account -> AccountStatus). I need that account_status model value (as a sqlalchemy object) to be available so that the QuerySelectField will "select" the current value when rendering the form. But since it is a RelationshipProperty instead of a Column property, I can't seem to get that to even allow me to declare the form, let alone instantiate it.
I must be missing something, because surely it is not this hard to do something this simple. The details around this problem are below.
The model looks like:
Since account_status_id is in the model, I added I added a relationship (account_status) in an attempt to make that sqlalchemy attribute available on the model itself.
However when trying to use this in a QuerySelectField:
wtforms_alchemy.exc.InvalidAttributeException: Model does not contain attribute named 'account_status'.
The form looks like:
How should I be doing this?