On Wed, Apr 15, 2009 at 5:39 PM, Justin Bronn <jbr...@gmail.com> wrote:

>
> > If it's docs links you want :) :
> >
> > http://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-ra...
>
> This isn't in the docs, but it also works:
>
> >>> qs = Foo.objects.all()
> >>> qs.query.as_sql()
>
> It returns a two-element tuple comprised of the generated SQL and
> parameters, respectively.  Personally, I prefer it over the
> connection.queries approach because you can look at the SQL without
> having to execute it.
>
> -Justin
> >
>
Using query.as_sql() doesn't work for any query which doesn't return a
queryset, include aggregate(), count() and update().

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to