If I have a CharField
in a Django model, and I try to filter it using a string pattern with the LIKE
operator, such as:
MyModel.objects.filter(text__like='he_lo')
Django returns the error:
django.core.exceptions.FieldError: Unsupported lookup 'like' for CharField or join on the field not permitted.
However, if I use manage.py dbshell
to run the raw SQL:
select * from myapp_mymodel where text like 'he_lo';
it runs just fine.
Why does Django disallow pattern matching in it's ORM even though Sqlite supports it?