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

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -