I have model:
class M(Model):
re = CharacterField(max_length=50, blank=true)
For example in table I have:
table m
----------------
| id | re |
----------------
| 1 | \d+ |
| 2 | \:abc |
----------------
I want to find some object which will match my input string (inp
) by regexp stored in re
field, see example:
inp = ":abc"
for m in M.objects.all():
if re.match(m.re, inp)
print("{} matched".format(m.id)) # 2 matched
But is it possible to perform match
on DB server? So replace .all()
to '.filter' with some expression?