'Django: How to filter model with multiple whitespaces?
I have a model with char field with values like this:
"Justin Roseman" (one single whitespace betwen words)
"Justin Roseman" (two whitespaces betwen words)
" Justin Roseman " (a lot whitespaces betwen words)
etc. etc...
I want get all records searching "Justin Roseman".
My database is MySQL.
I have tried the icontains function, but it does not work if there is more than one whitespace between words:
results = MyModel.objects.filter(name__icontains="Justin Roseman") # Only returns values whit one whitespace between words, none whit two or more whitespaces :(
Any ideas? please.
Maybe whit regex?
Thanks :D
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|