Replies: 2 comments 1 reply
-
https://aminalaee.dev/sqladmin/configurations/ |
Beta Was this translation helpful? Give feedback.
1 reply
-
Here is my half working hacky solution that basically monkey patches in some additional attributes only when the 'edit' form is being rendered. It then undoes it, so future renders are not affected. class UsersAdmin(ModelView, model=Users):
...
form_columns = ['email', 'organization', 'name']
form_widget_args_update = dict(email=dict(readonly=True))
...
class MyAdmin(Admin):
...
@login_required
async def edit(self, request: Request) -> Response:
identity = request.path_params["identity"]
model_view = self._find_model_view(identity)
# monkey patch the 'edit' specific form properties
if model_view.form_widget_args_update:
orig = model_view.form_widget_args
model_view.form_widget_args = model_view.form_widget_args_update
make_edit = await super().edit(request)
# undo change
if model_view.form_widget_args_update:
model_view.form_widget_args = orig
return make_edit
|
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
-
Some fields I would like to not be changeable after the object is created.
So on the edit form those fields would be disabled.
Beta Was this translation helpful? Give feedback.
All reactions