python - How to create mongoengine filter query from fields listed as string rather DocumentFields -


i trying write function can take filter query string , later want parse , create respective filter query used in mongoengine. tried using q() not working string.

working:

return q(id__istartswith=value) 

not working:

_query = 'id__istartswith=' + value return q(_query) 

any highly appreciated.

you can use keyword expansion.

_query = {'id__istartswith': value} return q(**_query) 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -