On Wed, Dec 8, 2010 at 5:21 PM, dgmyrs <dgm...@gmail.com> wrote:
> Hi, I am trying to work with an in clause in my sql in a raw sql
> statement.  A simplified example:
>
> <code>
>>>>Category.objects.raw('select * from app_category where name 
>>>>in(\'Restaurants\',\'Fast Food\')')[0]
> <Category: Fast Food>
> </code>
>
> So that works fine with the in clause hard coded in there, and I could
> simply build that sql string, but I am wondering if there is a way to
> use the parameters argument of raw?  I tried using a list with the
> strings, and just a string itself with the escaped quotes, but
> couldn't get either to work.
>
> Thanks
>

Why use raw? Why not just use the ORM?

Category.objects.filter(name__in=['Restaurants', 'Fast Food'])

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to