> In [3]: from django.db import connection > > In [4]: connection.queries > Out[4]: [] > > I tried a couple of page reloads, stuff I know is querying the > database, still nothing. > > Any idea what I'm doing wrong?
The connection.queries is only available within a session/transaction. Thus, you need to access it from within the view, but ensuring that it runs after all your DB-intensive code has been run. This usually means after the template has been generated, which makes it a bit trickier to send the queries to the resulting view. You can dump the queries to a file in a debugging environment, often something like result = render_to_response('foo.html', context) f = file('debug.txt', 'w') f.write(repr(connection.queries)) f.close() return result Alternatively, you can insert a import pdb; pdb.set_trace() line instead and use pdb to explore your context. Or, you can slip a "%s" into your template and then do something like return render_to_response( 'foo.html', context) % repr(connection.queries) ) which is an ugly hack, but like using "printf"-debugging. Just a couple ideas... -tkc --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---