2 %% works perfectly.
For future stumblers of this post.
CLASSNAME.objects.raw("select * from table where full_name like'%%ipod%
%nano%%' ") works!!

Thanks mrfunyon.
ps: This should be added to the doc.

On Jun 6, 9:03 pm, mrfunyon <[email protected]> wrote:
> Try using 2 %'s  in your query
> like this:
> CLASSNAME.objects.raw("select * from table where full_name like
> '%%ipod%%nano%%' ")
>
> On Jun 6, 6:17 pm, Gyanit Singh <[email protected]> wrote:
>
> > 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to