def home(request): collections = Collection.objects.all().order_by("name") raw_extent = Collection.objects.all().aggregate(Sum("extent"))["extent__sum"] extent = bytes2human(raw_extent) return render_to_response( "dl_collections/index.html", {"collections": collections, "extent": extent, "campuses": campuses} )
def UC(request, urlstuff): campus = get_object_or_404(Campus, slug=urlstuff) extent = bytes2human( Collection.objects.filter(campus__slug__exact=urlstuff).aggregate(Sum("extent"))["extent__sum"] or 0 ) collections = Collection.objects.filter(campus__slug__exact=urlstuff).order_by("name") return render_to_response( "dl_collections/campus.html", {"campus": campus, "collections": collections, "extent": extent, "campuses": campuses}, )
def human_extent(self): return bytes2human(self.extent)
def human_extent(self): return bytes2human(self.extent, format=u'%(value).1f\xa0%(symbol)s')