Source

onpython3yet / onpython3yet / home / views.py



from django.http import HttpResponse, HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.shortcuts import render_to_response, get_object_or_404
from django.template import loader, RequestContext

from packages.models import Package, MostRequiredPackages

def index(request):
    req = MostRequiredPackages.objects.all()
    total = Package.objects.all().count()
    offset = 20
    return render_to_response('home/index.html',
                              {'dependend_on_total': req.count(),
                               'total': total,
                               'most_depended_on': req[0:offset],
                               'offset': offset},
                              context_instance=RequestContext(request))