Changes between Version 15 and Version 16 of DjangoSpecifications/Core/SingleInstance
- Timestamp:
- Mar 25, 2008, 5:56:41 AM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DjangoSpecifications/Core/SingleInstance
v15 v16 57 57 return u"%s (%s)" % (self.title, self.type_of_article.name) 58 58 59 {% for article in Article.objects.filter(type=1) %} 60 {{ article.type_of_article }} 59 60 Context({'articles': Article.objects.filter(type=1)}) 61 62 {% for article in articles %} 63 {{ article }} 61 64 {% endfor %} 62 65 }}} 63 66 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.67 In 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. 65 68 66 69 If you have a great number of articles and a smaller number of articletypes the performance/memory hit is staggering because: