mongodb / flask-pymongo

PyMongo support for Flask applications
BSD 2-Clause "Simplified" License
721 stars 175 forks source link

search referncefield #148

Closed softwolves closed 3 years ago

softwolves commented 3 years ago

when i want use admin modelview ,i want add a column_searchable_list ,but which in the list is an referencefield , it not work

dcrosta commented 3 years ago

I'm afraid I don't understand your request. Can you show an example of what you want, or an error message that shows what's not working?

softwolves commented 3 years ago

I'm afraid I don't understand your request. Can you show an example of what you want, or an error message that shows what's not working?

example: my models class Application(db.Document): app_type = db.StringField(max_length=50, verbose_name="应用类型") repo = db.StringField(max_length=50, verbose_name="应用名称",Required=True,unique=True) meta = {'allow_inheritance': True} def str(self): return self.repo class Vminstance(Instance): ip = db.StringField(max_length=50, verbose_name="ip 地址",Required=True,Unique="true") app = db.ReferenceField('Application', reverse_delete_rule=4,DBRef=True,) env =db.StringField(max_length=20,choices=envs) my view from flask_admin.contrib.mongoengine import ModelView from flask_admin import Admin admin=Admin(name='BBTCMDB', template_mode='bootstrap3',base_template="layouts/base.html") class myview(ModelView): column_filters = ['app_type'] column_searchable_list = ('ip','app') admin.add_view(myview(Vminstance))

when search app,will execpt
mongoengine.errors.ValidationError: "re.compile('.srv-mapi-web.')" is not a valid ObjectId, it must be a 12-byte input or a 24-character hex string

dcrosta commented 3 years ago

This is an issue with MongoEngine, not with Flask-PyMongo. Please file it there.