I have a model with a ForeignKeyField which gets rendered as a select field in the create/edit form in Flask-Admin. I would like to restrict the choices in the select field with a custom query so the user only has access to their own source addresses.
All answers point I've found point in the direction of WTForms' QuerySelectField but that is only for SQLAlchemy and I am using Peewee.
It seems like a pretty common thing to do though, so any other way?
class BulkMessage(BaseModel):
title = CharField(null=True)
source_address = ForeignKeyField(
SourceAddress,
related_name='bulk_messages',
null=True
)