-
-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
Background
In the example below, assuming parent is a many-to-one field that maps to a QuerySelectField, The query_factory's callable (get_all_except_first) will not be used, it just returns all records of the model. On the other hand, using a normal form works as expected.
def get_all_except_first():
return Example.query.filter(Example.id != 1)
# This doesn't work
ExampleForm = model_form(
Example,
field_args={
"parent": {"query_factory": get_all_except_first}
...
}
...
)
# This works
class ExampleForm(FlaskForm):
parent = QuerySelectField(query_factory=get_all_except_first)
...Failed debugging attempts
Got confused when attempting to debug code similar to the example above (using model_form):
- Printing
field_argsin theconv_ManyToOnemethod shows thatquery_factorypoints to<function ModelConverterBase.convert.<locals>.<lambda> at 0x1076a3b80>. - Using the debugger to inspect
field_argsin theconv_ManyToOnemethod shows that it doesn't containquery_factory
Metadata
Metadata
Assignees
Labels
No labels