I am trying to write a Django query that will only match whole words. Based on the answer here, I\'ve tried something like:
result = Model.objects.filter(te
You might be able to get something by dropping the regex and using a few django lookups
result = Model.objects.filter(Q(text__contains=' someword ') |
Q(text__contains=' someword.') |
Q(text__istartswith = 'someword.' |
Q(text__istartswith = 'someword.' |
Q(text__iendswith = 'someword')
see here for docs.
I realize that's not so elegant (but makes for easy maintenance if you're not a fan of regex).