github pallets-eco/flask-admin v2.2.1

4 hours ago

Bugfixes:

  • BaseTimeBetweenFilter.validate() now returns False on invalid input instead of raising an exception.
  • Fix encoding for editing file in FileAdmin. Now it uses UTF-8 and accepts non-ASCII characters.
  • SQLAlchemy backend: conv_ARRAY now infers the array element's python_type and passes it through as the Select2TagsField coerce callable. Saving a Postgres ARRAY(Integer) / ARRAY(Float) column no longer fails with column "x" is of type integer[] but expression is of type text[] (closes #1724).
  • Fix sorting arrow direction in admin list view. Now it reflects the current sorting state (closes #2933).
  • MongoEngine fileadmin backend: downloading GridFS files now preserves their name and extension instead of saving them as file (closes #2916).
  • MongoEngine backend: stop reading the deprecated GridOut.contentType property. File downloads and list/form widgets now resolve the MIME type via metadata["content_type"], the GridFS document directly (for legacy data), or filename-based guessing (closes #2920).
  • MongoEngine backend: QueryAjaxModelLoader.format now handles unresolved DBRef values gracefully instead of crashing with AttributeError: 'DBRef' object has no attribute 'pk' (which surfaced as HTTP 500 from the autocomplete endpoint when a ReferenceField target was deleted). Broken references are shown as (missing: <collection>/<id>) so users can clear them (closes #2917).
  • Peewee backend: inline model forms now support form_extra_fields when the child form is autogenerated. Previously, inline forms ignored these fields because they bypassed get_form() and called model_form() directly.
  • SQLAlchemy backend: the Unique validator now resolves its session when it runs instead of capturing the session that was active when the form was scaffolded. With flask-sqlalchemy-lite, forms scaffolded inside a startup app_context() previously kept querying that context's Session, which was never committed, rolled back or closed, so one connection per process sat "idle in transaction" after the first save of a form with a unique column (and failed permanently with PendingRollbackError once the server dropped it). Both ModelView(Model, db) and the deprecated ModelView(Model, db.session) continue to work (relates to #2831).
  • Peewee backend: ModelView.get_one() now returns None when no record matches, instead of letting peewee's DoesNotExist propagate. Requesting the details, edit or delete view for an absent or malformed id no longer returns HTTP 500; it flashes "Record does not exist." and redirects, matching the other backends (closes #2924).

Type hints:

  • Type hints added to all functions and methods (some still use typing.Any where full typing not yet available)
  • Updated InlineBaseFormAdmin.get_form() to return type[BaseForm] | None rather than T_MODEL_VIEW | None
  • Minor type hinting improvements for peewee backend
  • Admin(index_view=...) now accepts a BaseView instance rather than AdminIndexView, allowing e.g. FileAdmin

Don't miss a new flask-admin release

NewReleases is sending notifications on new releases.