简体   繁体   中英

Flask-Admin: Workaround for fields with reserved names

I want to use flask-admin for an existing table which has a column named meta but flask-admin doesn't support this as it uses WTForms for which meta is a reserved keyword. I can not use an alias for this column as a lot of code is already written using this name.

Is there any way to make this work?

Or is there any other python package that works with SQLAlchemy while providing similar features to flask-admin or django-admin ?

I am not familiar with flask-admin , but I had similar issue and I solved it with synonym .

from sqlalchemy.orm import synonym

class SomeTable(Model):
    # Normal model definition here
    ...
    meta_data = synonym('meta')

You can use meta_data as a field in your form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM