On my site user should have an ability to filter numbers, like *123*321*, that will match “666 123 555 321 111″ or LIKE '%123%321%'.
By default django’s orm escapes %-sign. I can use regex, or raw query, but is there some workaround?
UPD: i’ll place it here for displaying another way.
integer_search = [] # for colorizing found substrings
if actual['integer']:
integer_match = filter(None, actual['international'].split('*'))
integer_search = integer_match
integer_match = ''.join('%s[[:digit:]]*' % i for i in integer_match)
integers = integers.filter(international__regex=integer_match)
Yes, Django replaces all the
%and_. From docs:I would recommend you to use extra method. It is not really raw sql, although looks hacky: