How can I make a field on a ModelView readonly?
class MyModelView(BaseModelView):
column_list = (\'name\', \'last_name\', \'email\')
I don't have enough reputation to comment on @thkang's answer, which is very close to what worked for me. The disabled attribute excludes the field from the POST data, but using readonly had the desired effect.
from wtforms.fields import TextField
class ReadonlyTextField(TextField):
def __call__(self, *args, **kwargs):
kwargs.setdefault('readonly', True)
return super(ReadonlyTextField, self).__call__(*args, **kwargs)