On 11/28/06, Eric Floehr <[EMAIL PROTECTED]> wrote: > >>> DEBUG=True > >>> from myapp.models.references import Stuff > >>> from django.db import connection > >>> p = Stuff.objects.all() > >>> print connection.queries > []
This doesn't add anything to 'connection.queries' because it hasn't actually executed a query yet; 'Stuff.objects.all()' is a QuerySet object, and won't be evaluated until you attempt to access objects contained in it. This is deliberate, so that repeated calls to QuerySet methods like 'filter', 'extra', etc. can be used to programmatically build up complex queries without hitting your database until you're ready to look at the objects returned. As soon as you access one or more objects in the QuerySet -- by slicing, indexing, iterating, etc. -- it will execute a database query and that query will show up in 'connection.queries'. -- "May the forces of evil become confused on the way to your house." -- George Carlin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---