Is possible to use column_formatters in edit view in Flask Admin?
Asked Answered
P

0

6

Is possible to use column_formatters in edit view in Flask Admin? When I add the following code it is rendering "random" in the list form view. But when it renders the edit view this field is raw not using the column_formatters. I debugged it and indeed is using _user_formatter method just for list view.

self.column_formatters = {'model': self._user_formatter,}

def _user_formatter(self,view, context, model, name):
    return "random"
Pikeperch answered 15/10, 2018 at 11:55 Comment(3)
In a few words: no, it is not possible. If a value would be shown formatted in edit view then it will be saved in such a formatted output. Could you add some information why you need it and what DB backend do you use? There are several other ways of achieving the desired result.Bing
One use case could be that you want to mask the password (e.g. display ********* instead of the hash value) and use your own formatter for this. Then of course you don't want the password to be saved as ********* in the edit view. Or, if you use a custom formatter that displays an ID as a tooltip, you don't want it to be saved with HTML code snippets. Imho it should be possible to have different formatters for different scopes (action views like view/edit) and a general formatter for all views of a certain field value.Capitoline
Did you find a Solution for this?Gompers

© 2022 - 2024 — McMap. All rights reserved.