-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Integer array field in postgress is not handled by flask admin properly #1724
Comments
A workaround: class Select2IntegerTagsField(Select2TagsField):
def process_formdata(self, valuelist):
super().process_formdata(valuelist)
self.data = [int(x) for x in self.data]
class StudentView(ModelView):
def scaffold_form(self):
form_class = super().scaffold_form()
form_class.course_ids = Select2IntegerTagsField("Course Ids", save_as_list=True)
return form_class
admin.add_view(StudentView(Student, session)) |
Hi. Will this be systematically fixed without workarounds? |
thanks! it's help me a lot |
what is the Select2TagsField Class you're inheriting from? |
Please review this fix #2003 |
For future generations.
from flask_admin.form.fields import Select2TagsField |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Integer array field in my table in postgres exists and work perfectly. I can create/apdate/insert/delete it with numbers.
Flask-admin sees and interprets that field by SQLAlchemy model. Field shows up with its content in edit form in flask-admin.
But whenever I try to save the form (regardless of editing or leaving contents of array field as is) I got error 500. Postgres throws an error:
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) column "courses_ids" is of type integer[] but expression is of type text[]
So it seems that flask-admin interprets my int array field as text array.
Is there any solution on how to instruct Flask-Admin that the array field is of type int ?
Sqlalchemy field declaration:
courses_ids = Column(ARRAY(Integer))
The text was updated successfully, but these errors were encountered: