I've tried the following query with Django,
def search(search_text):
q = Info.objects.filter(title__contains=str(search_text))
print q.query
The query that get printed is
SELECT "d"."id", "d"."foo" FROM "d_info" WHERE "d_info"."title" LIKE %hello% ESCAPE '\'
The query fails because the text after LIKE doesn't have quotes around it. The query succeeds when I run the query on the sql prompt with quotes around the text after LIKE like below
SELECT "d"."id", "d"."foo" FROM "d_info" WHERE "d_info"."title" LIKE '%hello%' ESCAPE '\'
How do I get Django to add the quotes around the search_text so that the query succeeds ?
I'm using Djanog with sqlite3