5

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"
Esteban S
  • 1,859
  • 5
  • 22
  • 43
  • 4
    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. – Sergey Shubin Oct 15 '18 at 13:14
  • 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. – colidyre Sep 15 '19 at 08:57
  • 1
    Did you find a Solution for this? – shalama Dec 18 '21 at 09:49

0 Answers0