1

I am trying to use Django QuerySet/Filter with Regular Expression to filter the records in my MongoDB database. For the Python packages, I'm using:

  • Django 4.0.3
  • djongo 1.3.6
  • pymongo 3.12.6

Here's my current attempt (code):

import re
from .models import User

regex = re.compile(pattern)
result = User.objects.filter(name__iregex=regex.pattern)

However, I get djongo.exceptions.SQLDecodeError every time I use the filter like above.
After looking through StackOverflow, I find out that I can filter by using Django raw but I still want to know if there are any other ways to make the above codes viable.

G.Huan
  • 143
  • 1
  • 7

0 Answers0