Skip to content

fix(peewee): support form_choices in Peewee ModelView#2853

Draft
hasansezertasan wants to merge 4 commits into
masterfrom
fix/peewee-form-choices
Draft

fix(peewee): support form_choices in Peewee ModelView#2853
hasansezertasan wants to merge 4 commits into
masterfrom
fix/peewee-form-choices

Conversation

@hasansezertasan
Copy link
Copy Markdown
Member

Summary

  • Override convert() in CustomModelConverter to check form_choices before delegating to wtfpeewee's default conversion, returning a Select2Field when choices are defined (matching the SQLAlchemy contrib behavior)
  • Add test for form_choices in the Peewee test suite
  • Add form_choices usage to the peewee_simple example

Fixes #2235

Test plan

  • pytest flask_admin/tests/peeweemodel/ — all 12 tests pass
  • Manual verification with peewee_simple example — status field renders as a Select2 dropdown

@hasansezertasan hasansezertasan force-pushed the fix/peewee-form-choices branch from 088044d to df74d47 Compare April 1, 2026 08:08
@hasansezertasan hasansezertasan marked this pull request as draft April 1, 2026 08:09
Override convert() in CustomModelConverter to check form_choices
before delegating to wtfpeewee's default conversion. When a field
has choices defined, return a Select2Field matching the behavior
of the SQLAlchemy contrib.

Respects form_overrides priority, builds kwargs with proper
validators and filters consistent with the parent converter.
@hasansezertasan hasansezertasan force-pushed the fix/peewee-form-choices branch from df74d47 to c29d873 Compare April 1, 2026 08:12
@hasansezertasan hasansezertasan force-pushed the fix/peewee-form-choices branch from c29d873 to 9968e0e Compare April 1, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

form_choices for flask_admin.contrib.peewee.ModelView doesn't work

2 participants