on_model_change/on_model_delete does not work #390
Unanswered
BohdanSizomin
asked this question in
Q&A
Replies: 1 comment
-
|
can you provide the Sensor model? i tested a example UserAdmin with the example User model (with configs like your's) and callback methods work, i think the problem might be in your Sensor model. class User(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True)
name = Column(String)
class UserAdmin(ModelView, model=User):
async def on_model_change(self, data, model, is_created):
# Perform some other action
print(model, " changed")
async def on_model_delete(self, model):
# Perform some other action
print(model, " deleted")
can_create = True
can_edit = True
can_view_details = True
column_list = [User.id, User.name]
column_sortable_list = [User.name, User.id]
name = "User"
name_plural = "User"
icon = "fa-solid fa-sensor"
column_searchable_list: list = [User.name]
form_columns: list = [User.name]
column_details_list: list = [User.id, User.name]
page_size = 50
page_size_options = [50, 100, 200] |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
My code is above
All I want is to calculate the field based on another field
But unfortunately whenever I'm creating/deleting a model those methods are not being called
Maybe I`m doing something wrong ?
I really appreciate any help you can provide
Beta Was this translation helpful? Give feedback.
All reactions