-def counters(request):
- books = models.Book.objects.count()
- books_nonempty = models.Book.objects.exclude(html_file='').count()
- books_empty = models.Book.objects.filter(html_file='').count()
- books_root = models.Book.objects.filter(parent=None).count()
-
- media = models.BookMedia.objects.count()
- media_types = models.BookMedia.objects.values('type').\
- annotate(count=Count('type')).\
- order_by('type')
- for mt in media_types:
- mt['size'] = sum(b.file.size for b in models.BookMedia.objects.filter(type=mt['type']))
-
- return render_to_response('catalogue/counters.html',
- locals(), context_instance=RequestContext(request))
-
-