On Sun, Jan 18, 2009 at 5:27 PM, phoebebright <phoebebri...@spamcop.net> wrote: > > I have a problem with the sql being generated by this: > > tasks = Task.objects.filter(status='open').order_by('-priority') > tasks = tasks.extra(where=['list IN %s'], params= > [settings.MY_LISTS]) > > Is there a command where I can say something like 'print tasks.sql' > that would generate the sql but not send it to the database, so I can > see exactly why the sql is failing?
First, you can try what's suggested at this Django FAQ entry: http://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-raw-sql-queries-django-is-running For another option, try printing the output of: <QuerySet instance>.query.as_sql() or if you are using a recent trunk version (more recent than two weeks or so) you might want to try printing the output of: <QuerySet instance>.as_sql() They should print the complete SQL query generated by the QuerySet. Both the query attribute and as_sql() method are internal implementation details of QuerySet. That's why they are not documented, but you can count on them being present for the foreseeable future. HTH -- Ramiro Morales --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---