syrusakbary / Flask-SuperAdmin

The best admin interface framework for Flask. With scaffolding for MongoEngine, Django and SQLAlchemy.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to handle read only fields in add view

iurisilvio opened this issue · comments

The commit ab23b39 broke the add view when the model has readonly fields. It happens because the form exclude readonly fields. It is fine to the edit view, but does not work to add view.

Should we split the model_form in something like edit_model_form and add_model_form or we have a better solution to it?

I've got this issue now... Whenever I add a readonly_fields tuple to a ModelView definition, Superadmin fails:

UndefinedError: 'instance' is undefined

After digging about in the code, it indeed looks like the reason that it doesn't work is that the add function doesn't hand the instance to the render function. Any news on when this might be possibly fixed?