We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I was trying to add a default filtering to an inline model, but got the following error.
TypeError: __init__() got an unexpected keyword argument 'query_factory'
Spent several hours on this but can't figure out how to solve it.
The following is the code causing error. I just added the following form_args to the sqla-inline example.
class LocationAdmin(ModelView): inline_model_form_converter = CustomInlineModelConverter inline_models = (InlineModelForm(),) form_args = { 'images': { 'query_factory': lambda: db.session.query(LocationImage) } } def __init__(self): super(LocationAdmin, self).__init__(Location, db.session, name='Locations')
The text was updated successfully, but these errors were encountered:
Had a same issue. Succeeded with overriding 'query_factory' of embedded form inside create_form/edit_form. In your case it probably will be following:
def create_form(self, obj=None): form = super().create_form(obj) form.images.form.image.kwargs['query_factory'] = lambda: db.session.query(LocationImage) return form
Sorry, something went wrong.
No branches or pull requests
I was trying to add a default filtering to an inline model, but got the following error.
TypeError: __init__() got an unexpected keyword argument 'query_factory'
Spent several hours on this but can't figure out how to solve it.
The following is the code causing error. I just added the following form_args to the sqla-inline example.
The text was updated successfully, but these errors were encountered: