On Feb 21, 7:32 pm, diafygi <diaf...@gmail.com> wrote:
> There's a previous thread about this[1], but it was closed back in
> 2006 without resolution. So I'd like to check back in and see if there
> is a way to get a complete query string without executing the query.
>
> At first, I thought I could just use the QuerySet.query.__str__(), but
> that does not put quotes around dates, so MySQL returns a warning when
> trying to execute it. I filed a bug report[2], but apparently
> QuerySet.query.__str__() isn't supposed to return a valid query
> string.
>
> So is there a way to get the compiled query string without executing
> the query (including when debug=False)?
>
> Thanks!
> Daniel
>
> [1] -http://groups.google.com/group/django-users/browse_thread/thread/37a6...
> [2] -https://code.djangoproject.com/ticket/17741

What I usually do is set a breakpoint with pdb at the appropriate
place ('import pdb; pdb.set_trace()') then run the devel server, and
then you hit the breakpoint do 'print queryset.query'

There's also this:

https://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-raw-sql-queries-django-is-running

But I've never tried it.

-larry

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