Reputation: 869
I have a sqlalchemy model:
class Multicast(db.Model):
__tablename__ = "multicast"
id = Column(Integer, primary_key=True)
addr = Column(Inet)
name = Column(Unicode(65))
I need to make search by "addr" field. I could not do it in this way:
class MulticastView(ModelView):
column_searchable_list = ('name', 'addr',)
column_filters = ('name', )
model = Multicast
Because i had an Exception: Can only search on text columns. Failed to setup search for "addr". How can i make this search?
Upvotes: 1
Views: 1159
Reputation: 7
Another option here is to modify the allowed_search_types for the MulticastView class:
class MulticastView(ModelView):
allowed_search_types = (
mongoengine.StringField,
mongoengine.URLField,
mongoengine.EmailField,
mongoengine.Inet
)
...
Upvotes: 0
Reputation: 869
I found some solution. I overrided get_list method in MulticastView. I copied all source code from ModelView and added a line in search criteria code:
filter_stmt.append(func.text(Multicast.addr).like(stmt))
It works!
Upvotes: 1