-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overriden form text field with FileUpload field. #723
Comments
I think I understand what the issue is, but this was specifically added to make sqladmin work with fastapi-storages. |
Yeah, I use JSONB field in SQLAlchemy, override it with FileUpload field in the admin form, parse json from the file in the |
This comment was marked as outdated.
This comment was marked as outdated.
@smbrine I think I was a bit confused and my previous comment was not accurate. |
Because in that case there will be no way to submit a file (except for fully custom form but it's definitely not what I want since it takes way more time to do). |
But is this accomplished in any tool like Django admin and flask-admin without modifying the behaviour completely? The reason I ask is that is that this is a very specific use-case that you want the create form to accept a file, but in the edit form you want to edit a JSON field. |
Seems like I have incorrectly explained my point. It's not that I want to have a JSON field in the edit form, there is also |
Checklist
master
.Describe the bug
Since I already have a solution but I don't know whether it's useful or not, I will be short. I have a simple logic in my app. User can upload a
.json
file,async def on_model_change(self, data, model, is_created, request):
will open it, load json and pass it further as a dict to save it to postgres'JSONB
field. The problem is that the SQLAdmin itself still considers it being of typeUploadFile
and hence line 689 inapplication.py
was raising anAttributeError: 'dict' object has no attribute 'name'
. My solution is to basically just passf
's value as is since there's no case whenf
can havename
orread
attribute in this elif.Steps to reproduce the bug
No response
Expected behavior
No response
Actual behavior
No response
Debugging material
os, python, sqladmin version
Environment
Additional context
No response
The text was updated successfully, but these errors were encountered: