From 6036a48383176466b270ce27d3b72630cec6a2ee Mon Sep 17 00:00:00 2001 From: eqperes Date: Tue, 16 Jul 2024 10:45:48 +0200 Subject: [PATCH] allow GeneralModelConverter to be overridden by setting the class to a property --- flask_appbuilder/baseviews.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/flask_appbuilder/baseviews.py b/flask_appbuilder/baseviews.py index ad1dc73795..035a20518c 100644 --- a/flask_appbuilder/baseviews.py +++ b/flask_appbuilder/baseviews.py @@ -581,6 +581,9 @@ class MyView(ModelView): search_widget = SearchWidget """ Search widget you can override with your own """ + model_converter = GeneralModelConverter + """ Use this property to set a custom model converter """ + _base_filters = None """ Internal base Filter from class Filters will always filter view """ _filters = None @@ -630,7 +633,7 @@ def _init_properties(self): self._filters = self.datamodel.get_filters(self.search_columns) def _init_forms(self): - conv = GeneralModelConverter(self.datamodel) + conv = self.model_converter(self.datamodel) if not self.search_form: self.search_form = conv.create_form( self.label_columns, @@ -883,7 +886,7 @@ def _init_forms(self): Init forms for Add and Edit """ super(BaseCRUDView, self)._init_forms() - conv = GeneralModelConverter(self.datamodel) + conv = self.model_converter(self.datamodel) if not self.add_form: self.add_form = conv.create_form( self.label_columns,