Making query with LIKE where __contains is not enough.
Hi All,
As start I know there is __contains [http://docs.djangoproject.com/en/
dev/ref/models/querysets/#contains]. But it only does LIKE '%word%'
query.
I want to do LIKE '%word1%word2%' query.
for e.g. select * from table where column LIKE '%ipod%nano%'.
The raw sql query is trying to replace percentage and throwing error
that there are no parameters.
both CLASSNAME.objects.raw("select * from table where full_name like
'%ipod%nano%' ")
CLASSNAME.objects.raw("select * from table where full_name like '\%ipod
\%nano\%' ")
throws
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python26\lib\site-packages\django\db\models\query.py", line
1376, in __repr__
return "<RawQuerySet: %r>" % (self.raw_query % self.params)
TypeError: not enough arguments for format string
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home