Reputation: 37
Is it possible django 1.4
SELECT * FROM table WHERE columname regexp 'a|z|f'
I tried multiple filter with 'or' operator
Upvotes: 0
Views: 108
Reputation: 2017
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')
Upvotes: 1