Gary Wilson wrote: > I see that there is a _get_sql_clause() method, but is there a function > that will return the constructed query string?
You can just do the same construction that's done in django/db/models/query.py: >>> from danet.blog.models import Post, Tag >>> qs = Tag.objects.filter(title__icontains='a', description__icontains='n') >>> cols, sql, args = qs._get_sql_clause() >>> "SELECT %s %s" % (', '.join(cols), sql % tuple(args)) 'SELECT `blog_tag`.`slug`, `blog_tag`.`title`, `blog_tag`.`description` FROM `b log_tag` WHERE (`blog_tag`.`description` LIKE %n% AND `blog_tag`.`title` LIKE %a %) ORDER BY `blog_tag`.`title` ASC' >>> There's some special handling for DISTINCT if you look at django.db.models.query.iterator(), but the snippet above is close enough. After a while you get used to just looking at the list from _get_sql_clause() directly and can just add the "SELECT" and replace the args in your head. -Dave --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---