Comments (6)
@okapies After the PR was merged you should be able to override this behaviour by setting form_overrides
.
But I see you've proposed a solution which might be simpler, I will take a look next week. Thank you for the contribution.
from sqladmin.
Hi,
To be honest, I think we should first start integrating SQLModel first, and see how it goes.
After that we can decide to allow custom converters and how we can approach that.
Thanks for the suggestion.
from sqladmin.
I've created a PR for SQLModel support, but I think this will solve the issue here too.
#94
Basically this will enable classes inheriting from TypeDecorator
and handle them properly.
from sqladmin.
Nice! However the PR does break sqlalchemy_utils.types.ChoiceType
File "/Users/app/.venv/lib/python3.9/site-packages/sqladmin/models.py", line 635, in scaffold_form
return await get_model_form(
└ <function get_model_form at 0x104e04a60>
File "/Users/app/.venv/lib/python3.9/site-packages/sqladmin/forms.py", line 297, in get_model_form
field = await converter.convert(
│ └ <function ModelConverterBase.convert at 0x104e1b550>
└ <sqladmin.forms.ModelConverter object at 0x1078f2fa0>
File "/Users/app/.venv/lib/python3.9/site-packages/sqladmin/forms.py", line 105, in convert
converter = self.get_converter(prop)
│ │ └ <ColumnProperty at 0x105a27240; schedule_type>
│ └ <function ModelConverterBase.get_converter at 0x104e1b4c0>
└ <sqladmin.forms.ModelConverter object at 0x1078f2fa0>
File "/Users/app/.venv/lib/python3.9/site-packages/sqladmin/forms.py", line 75, in get_converter
if col_type.impl.__name__ in self.converters: # type: ignore
│ │ │ └ {'Boolean': <bound method ModelConverter.conv_Boolean of <sqladmin.forms.ModelConverter object at 0x1078f2fa0>>, 'dialects.ms...
│ │ └ <sqladmin.forms.ModelConverter object at 0x1078f2fa0>
│ └ Unicode(length=255)
└ <class 'sqlalchemy_utils.types.choice.ChoiceType'>
AttributeError: 'Unicode' object has no attribute '__name__'
One benefit of being able to register custom converters is so that you can bypass the usual ModelConverter
flow. Passing in form_overrides
doesn't work either since it tries to get the converter before it looks at override
from sqladmin.
It seems this issue has not been solved yet, right? I need to add my converter to support the custom column types. @aminalaee
ref. #176.
from sqladmin.
Thanks, I'll try it. IMHO, I think it may be useful if ModelAdmin
accepts converters
setting (type -> ConverterCallable
or column -> ConverterCallable
?) that customizes ModelConverter
.
from sqladmin.
Related Issues (20)
- Static file over https in AWS with ECS and LoadBalancer HOT 16
- CSS and Javascript files for the Admin not loaded HOT 2
- Overriden form text field with FileUpload field. HOT 7
- Not able to edit fields in sql admin when using s3 filetype HOT 3
- Unexpected main page view HOT 6
- Add ModelView.form_query property to create form-filtering feature HOT 2
- override delete model method to perform soft delete HOT 1
- form_overrides doesn't work HOT 2
- SqlAlchemy dataclass support missing HOT 6
- Multiple Admin Instances result in wrong URL's to the views HOT 1
- Ajax query passes incorrect urn when admin mounted on sub fastapi app HOT 3
- Sort symbol is incorrect (wrong direction)
- sqladmin + jinja templates conflict index.html HOT 3
- Raised value error HOT 5
- Define default values via form_args
- TypeError: UUID objects are immutable (fastapi_users) HOT 4
- ValueError on passing unexcepted parameter
- Use HTMX HOT 3
- jinja2.exceptions.TemplateNotFound: list.html HOT 3
- What about Router per View? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqladmin.