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
Post a Comment