In Django data model, Consider that we have a text like this:
I am going to go somewhere.
If I use the Entity.objects.filter(column__contains="go")
, it will return going
word as well. But I only want the go
word to be returned.
Is there any solution other than using Full Text Search
?
2
Answers
After checking the Regex document for Django (thanks to Joshlsullivan), This solution worked for me.
In my case,
searched
is a variable and changes over time (It is not always the wordgo
as in my question). Using{}
I was able to add a variable to the regex string.s
means white space.You can loop through the queryset and then return entries with the word in the string. Try something like this: