[Answer]-How to use mysql regexp in django1.4

1👍

You can perform any SQL query using Django just by using custom SQL. Your example would be something like:

for i in Item.objects.raw("SELECT * FROM table WHERE columname regexp 'a|z|f'")

But you need to be careful with these because changing your database engine in future might lead to these queries breaking if the new engine uses a different syntax or doesn’t support some of the feature’s you’re using.

Using the Django ORM itself you’ll need something like:

for i in Item.objects.filter(columname__regex=r'a|z|f')

Leave a comment