Changes between Version 2 and Version 3 of Ticket #23662


Ignore:
Timestamp:
Oct 16, 2014, 4:09:37 AM (10 years ago)
Author:
Akis Kesoglou
Comment:

Ditto

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #23662 – Description

    v2 v3  
    1 Current implementation:
    2 https://github.com/django/django/blob/master/django/db/models/query.py
     1Current implementation: https://github.com/django/django/blob/master/django/db/models/query.py
    32
    43{{{
     
    1413}}}
    1514
    16 These methods call self._fetch_all(), thus evaluating the queryset. Although, this behaviour is documented (https://docs.djangoproject.com/en/1.7/ref/models/querysets/#when-querysets-are-evaluated), it is not obvious.
     15These methods call `self._fetch_all()`, thus evaluating the queryset. Although, this behaviour is [https://docs.djangoproject.com/en/1.7/ref/models/querysets/#when-querysets-are-evaluated documented], it is not obvious.
    1716
    18 It seems logical to evaluate queryset, when casting it to a list() or iterating over it, but these particular cases have nothing to do with the queryset contents. There exist specific lazy methods (QuerySet.exists() and QuerySet.count() respectively) which, IMHO, should be used for the magic method implementation.
     17It seems logical to evaluate queryset, when casting it to a `list()` or iterating over it, but these particular cases have nothing to do with the queryset contents. There exist specific lazy methods (`QuerySet.exists()` and `QuerySet.count()` respectively) which, IMHO, should be used for the magic method implementation.
    1918
    20 If I already have fetched the results of a queryset, I'm okay to call __len__() on them, but if they haven't been retrieved yet, I'd rather use SQL COUNT() instead. That is exactly, what QuerySet.count() does. The same goes for the __nonzero__() and exists().
     19If I already have fetched the results of a queryset, I'm okay to call `__len__()` on them, but if they haven't been retrieved yet, I'd rather use `SQL COUNT()` instead. That is exactly, what QuerySet.count() does. The same goes for the `__nonzero__()` and `exists()`.
Back to Top