Implement Django __iin custom lookup -


i read django documentation on custom lookups, failed figure out how implement case-insensitive __in lookup.

anyone can help? i'm on django 1.10 postgresql database.

there's no need of __iin lookup implementation. can use iregex this:

result = mymodel.objects.filter(field__iregex=r'(test1|test2|test3)') 

or more generic approach:

a = ['test1', 'test2', 'test3'] to_lookup = '|'.join(a)  # 'test1|test2|test3'  result = mymodel.objects.filter(field__iregex=r'(' + to_lookup + ')') 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -