On 08/12/10 17:42, dgmyrs wrote:
> That's a simplified sql just as an example.  The actual one I need the
> in clause is a lot more complex and can't be handled in the ORM.
> 

[Are you _sure_? name__in=... is so much handier, django sorts it out
for you...]

Anyway, see also
http://code.djangoproject.com/browser/django/trunk/django/db/models/sql/where.py#L177

Build up a parameterised query string dynamically (eurgh, I know):

l = ('Restaurants','Fast Food',)

pquery = "SELECT id FROM app_category WHERE name IN (%s)" % ',
'.join(["%s"]*len(l))

Category.objects.raw(pquery, l)[0]




-- 
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