Skip to content

Commit

Permalink
allow GeneralModelConverter to be overridden by setting the class to …
Browse files Browse the repository at this point in the history
…a property
  • Loading branch information
eqperes committed Aug 22, 2024
1 parent 3030e88 commit 3e937fc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions flask_appbuilder/baseviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 3e937fc

Please sign in to comment.