Unverified Commit 619699b6 authored by ufo911's avatar ufo911 Committed by GitHub

Added ReferenceField Search

parent e9da9b29
......@@ -140,7 +140,8 @@ class ModelView(BaseModelView):
allowed_search_types = (mongoengine.StringField,
mongoengine.URLField,
mongoengine.EmailField)
mongoengine.EmailField,
mongoengine.ReferenceField)
"""
List of allowed search field types.
"""
......@@ -466,7 +467,12 @@ class ModelView(BaseModelView):
criteria = None
for field in self._search_fields:
flt = {'%s__%s' % (field.name, op): term}
if type(field) == mongoengine.ReferenceField:
import re
regex = re.compile('.*%s.*' % term)
else:
regex = term
flt = {'%s__%s' % (field.name, op): regex}
q = mongoengine.Q(**flt)
if criteria is None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment