Changes between Version 15 and Version 16 of DjangoSpecifications/Core/SingleInstance


Ignore:
Timestamp:
Mar 25, 2008, 5:56:41 AM (17 years ago)
Author:
Philippe Raoult
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DjangoSpecifications/Core/SingleInstance

    v15 v16  
    5757        return u"%s (%s)" % (self.title, self.type_of_article.name)
    5858
    59 {% for article in Article.objects.filter(type=1) %}
    60 {{ article.type_of_article }}
     59
     60Context({'articles':  Article.objects.filter(type=1)})
     61
     62{% for article in articles %}
     63{{ article }}
    6164{% endfor %}
    6265}}}
    6366
    64 In the above example, type is only queried for once, because each iteration it knows that it's already in memory via the instance caching. This is a '''very''' common use case for many developers.
     67In the above example, type_of_article should only be queried for once, because it's already in memory. This is a '''very''' common use case for many developers.
    6568
    6669If you have a great number of articles and a smaller number of articletypes the performance/memory hit is staggering because:
Back to Top