Commit 5e2ce24e authored by fred's avatar fred

performance: compute queries in context (not in every nested templates)

parent 3b192ad0
......@@ -182,9 +182,9 @@ class News(TemplateView):
def get_context_data(self, **kwargs):
context = super(News, self).get_context_data(**kwargs)
context['newsImaged'] = NewsItem.objects.all().exclude(image__isnull=True).exclude(image__exact='').order_by('-datetime')[:3]
context['news'] = NewsItem.objects.all().order_by('-datetime')[:60]
context['categories'] = NewsCategory.objects.all()
context['newsImaged'] = list(NewsItem.objects.all().exclude(image__isnull=True).exclude(image__exact='').order_by('-datetime')[:3])
context['news'] = list(NewsItem.objects.all().order_by('-datetime')[:60])
context['categories'] = list(NewsCategory.objects.all())
context['player'] = audioPlayer()
return context
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment